Whys this code not working?

I’d imagine this is a super easy fix and i’m just being stupid, but basically this code is in the starter player script and it not working.

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local ff = Instance.new("ForceField")
ff.Parent = player
ff.Visible = false

I also have a script in the starter character script which isn’t working either.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

character.Humanoid.WalkSpeed = 100

Are you sure these are local scripts? Server scripts can’t access LocalPlayer.

You need to parent this to the character instead.

3 Likes

Thank you I will try that, and yes these are both local scripts (btw I get no error messages)

Edit: I added player.character and it is still not working

1 Like

Now, second script is working but only for client since you change walkspeed locally not from server which is what some hackers do for hacking your experience. You should change humanoid’s speed from server side not from local script.

1 Like

Ok thank you, how would I go about doing this?

If you want to change people’s character from server side when character is added all you need to do is:

game.Players.PlayerAdded:Connect(function(plr) 
	plr.CharacterAdded:Connect(function(chr)
		chr:FindFirstChild("Humanoid").WalkSpeed = 100
	end)
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.