How to disable a script from another script.

So I’m a complete noob when it comes to unity and c# ( I only started playing with it about 2 months ago) I’m currently creating an endless runner that when you collide with an obstacle the player can rewind time by hold spacebar.

All these things work fine but while the rewinding time works the spawn point continues to spawn new enemies.

After watching a few tutorials and trying to do it myself I’m here to see if anyone can help.

I’m tried creating

Public GameObject Spawn;
Attached the spawn point object with the script attached.
And trying to call it on

If (Input.GetKeyDown(Keycode.space))
Spawn.GetComponant().enabled = false;

And

And the reverse when space is released.

But I can’t seem to get it to work, I would very appropriate of anyone who could offer some help.

Thanks.

Without more context of how your code is setup, it’s hard to say why it doesn’t work. You’ll probably want to show your code for both your spawning and your disable/enable code a bit more so we can help you out.

Also note, in case it’s not a typo.

KeyCode.Space

requires the Space to be capital.

Can you elaborate on what you mean by it not working? Are you getting compile errors, or is it just not working the way you want when you play the game? What’s happening instead of what you want to happen?