How can i disable other players scripts when i press a key?

I’d like it so when a player presses a certain key, they can disable all other players StarterPlayerScripts to prevent spam in my game

I tried doing the follwowing code (My mentor made a few comments and edited the code)

Code
	for i, v in pairs(game:GetService("Players"):GetPlayers()) do

			if v ~= plr then
                --[[for i, v in pairs(v.Character:GetChildren()) do
                    if v:IsA("BasePart") then
                        v.Humanoid.WalkSpeed = 9
                    end
                    Baseparts dont have humanoids. Why did you add this?
                    ]]
				local VChar = v.Character or v.CharacterAdded:Wait()
				VChar:WaitForChild("Humanoid").WalkSpeed = 9
				game.StarterPlayer.StarterPlayerScripts.ControlToRun.Disabled = true
 v.PlayerScripts.TimeStop.Disabled = true
v.PlayerScripts.TimeSlow.Disabled = true
v.PlayerScripts.TimeFreeze.Disabled = true
			end
		end

``

But it didnt work out

Ive looked on the devforum for anything about disabling starter player scripts but i couldnt find anything

Not entirely sure what you mean by “prevent spam”. You are on the right track.

Also, notice this why not have those types of scripts within StarterCharacterScripts?

You do

game.StarterPlayer.StarterPlayerScripts

and

 v.PlayerScripts

what are you trying to disable? Its unclear because you already have what you would need to solve your problem. That’s why I just need a little more clarification on what your trying to achieve.

When a player pressed Q, E, or R in my game the saturation changes, and as of now its currently spammable. I want it so that it wont spam to prevent people with epilepsy to not have an epileptic episode

Basically, Lets say there are 2 players in my game.

Player 1 presses Q, doing something (lets say player 2 was anchored because player 1 presses Q.)

As of now, player 2 can press Q and anchor player 1, but they [Player 2} wont be unanchored.

I want it so that if player 1 presses Q, player 2’s starter character scripts will disable preventing that

Preventing spam could be done some other way instead of disabling scripts. I take it for the client to be able to do these Moves they need a fire a remote you can just add a debounce with the remote preventing any sort of excessive usage.

1 Like

That sounds like a good idea, but what is debounce? im still kinda a beginner :sweat_smile:

1 Like

Heres a tutorial from Documentation -

basically define a bool which you will add a conditional before running code

1 Like