Can someone please explain why I am getting this error?

I have a local script in the player.PlayerScripts that is my script that makes it so people can sprint. I want to disable it with a server script but every time I do I get this error :

PlayerScripts is not a valid member of Player “Players.Mioxity” - Server - runScriptDisable:2

Why am I getting this when PlayerScripts most definatey is a part of the player?
Here is my script :
game.ReplicatedStorage.events.scriptDisabler.OnServerEvent:Connect(function(plr)

plr.PlayerScripts.sprintScript.Disabled = true

wait(6)

plr.PlayerScripts.sprintScript.Disabled = false

end)

1 Like

U can’t acces PlayerScripts via Server Script

Then how can I get this to work?

You can try creating a BoolValue named CanSprint and check if CanSprint.Value is true, and when you want to disable it, just set CanSprint.Value to false

You can put this script in StarterPack

This works but the issue im having is that if the sprint key is held down if the player is dead and then let go once the player respawns , the player has half of the default speed which is a bug I am trying to fix , I thaught disabling the script would rule out the userImputService.InputEnded but it seems it has not.

What is the source of your local script?

Like what is the local scripts parent?

I wanna see the code of the local script

local UIS = game:GetService(“UserInputService”)
local char = game.Workspace:WaitForChild(game.Players.LocalPlayer.Name)

UIS.InputBegan:Connect(function(key,processed)
if key.KeyCode == Enum.KeyCode.LeftShift and not processed then
char.Humanoid.WalkSpeed *= 2
end
end)

UIS.InputEnded:Connect(function(key,processed)
if key.KeyCode == Enum.KeyCode.LeftShift and not processed then

	char.Humanoid.WalkSpeed /= 2
end

end)

char.Humanoid.Died:Connect(function()
game.ReplicatedStorage.events.scriptDisabler:FireServer()

end)

You better set a certain value instead of dividing and multiplying
Like:
speed = value
(on shift key pressed)
char.Humanoid.WalkSpeed = speed*number
or making a special variable for sprint speed

I know but I can’t do that because there are other things in the game that alter the speed of the player and I need the speed to stay in a fixed ratio.

Edit: That would work if player speed could go into the negatives.

Hmm. Make an IntValue of your character speed.

Oh I see then let me try that.

This works perfectly , that you for helping me out .

In future enclose your code in a pair of three backticks in order to properly format it.

print("Hello world!")