I am trying to set up a different speed when the player is walking on cobblestone, I have the following script and place it on StarterGui without luck. (also tried placing it in other places and even tried it as a server script in ServerScriptService.
if game.Players.LocalPlayer.Character.Humanoid.FloorMaterial == "Cobblestone" then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 30
print("cobblestone")
else
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
end
end)
if game.Players.LocalPlayer.Character.Humanoid.FloorMaterial == Enum.Material.Cobblestone then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 30
print("cobblestone")
else
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
end
Also, you can’t use LocalPlayer on a server script.
like people have said before me, use Enum.Material .Cobblestone and put it in starter character but i would add a loop to it since the script only checks one time if ur on cobblestone
First of all, server scripts cannot access LocalPlayer as it’s a nil value in the Server. You should try putting it has a local script in StarterPlayer> StarterCharacterScripts or StarterPlayerScripts (Depends on the script)
Try threading it in a while loop or RunService. Or another thread thing! it might be checking when the player is spawned, and do not detect it again while you’re running. I hope my explanation makes sense.
Edit: I tried it on my place with while loop in StarterCharacterScript. and it worked!
I wish I could set a few of the answers as solution. BIG thank you for everyone to jump in and help, these is one of those easy solvable issues that was right in front of my eyes, and I hope all of your answers can help others with the same inquire.
You rock! let’s get these devs some hearts!(likes)