help plz
script.Parent.Touched:Connect(function() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 64 end)
Your code should work as long as you use a local script
, but you can try to find the character
a different way.
Your code:
script.Parent.Touched:Connect(function() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 64 end)
You could also change :Connect(function()
to :Connect(function(character)
(allowing you to establish who the character is easier):
script.Parent.Touched:Connect(function(character) character.Humanoid.WalkSpeed = 64 end)
If all else fails check out these links:
game:GetService("Players").LocalPlayer
only works for LocalScripts
, BUT, you can get the player through Character (which you don't actually need in this case because you're editing a property of the Humanoid which is in the character):
script.Parent.Touched:Connect(function(Hit) if Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then Hit.Parent.Humanoid.WalkSpeed = 64 end end)
IF you want a players only then:
script.Parent.Touched:Connect(function(Hit) if Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then local IsPlayer = game.Players:GetPlayerFromCharacter(Hit.Parent) if IsPlayer then Hit.Parent.Humanoid.WalkSpeed = 64 end end end)
Good luck!