I want to be able to make 5 daedaric arrows after 200 frames when pressing Q but it doesn't work. The editor thinks it's fine though.
scriptname time
float time
begin gamemode
let time -= 1
if getkeypress 16 && time < 0
player.additem 0001EFD3 5
set time to 200
endif
end
If you want to have this executed after exactly 200 frames, you're assuming that your script will run every single frame.
This is only true for object type scripts, which are attached to a base object. As long as a reference of this object is loaded ingame (i.e. it is "physically" present in a loaded cell), the script will be run for every frame as expected.
Once you leave the cell, execution will be suspended, unless you haven't unchecked the "No low-level processing" flag for that specific reference.
Be aware that such "run-every-frame" code can put heavy load on your CPU and therefore is not a good practice (unless explicitely needed).
In contrary, quest type scripts (attached to a quest) will run in a 5 seconds interval by default (which can be changed by setting a value for fQuestDelayTime). This is much more recommended. As the 5 sec might cause problems with keyPressed detection, you should consider placing your code in a quest script anyway, but changing fQuestDelayTime to a lower value, such as 0.2 or 0.1.
Example:
ScriptName MyQuestScriptfloat fQuestDelayTimeshort doOnceshort questEndedbegin gameMode if doOnce == 0 set fQuestDelayTime to 0.2 set doOnce to 1 endif [... your key detection code goes here ...]end
As a good practise, once your "run-very-often" logic isn't needed anymore (e.g. if the parent quest is completed), try to change fQuestDelayTime back to normal (i.e. a value of 5 or higher).