Hey I am trying to make a script that changes a players walkspeed and team when they touch a part but I get this error
We have managed to get the team switching done but we are having issues with the walkspeed, we have tried changing stuff around but have found no solution. Me and my friend are new to scripting so any help would be appreciated!
Here is our code
part = script.Parent
script.Parent.CanCollide = false
script.Parent.Anchored = true
part.Touched:Connect(function(TouchedObject)
if TouchedObject.Parent:FindFirstChild("Humanoid") then
print("Switching..")
game.Players:GetPlayerFromCharacter(TouchedObject.Parent).Team = game.Teams["Stage 1"]
game.Players:GetPlayerFromCharacter(TouchedObject.Parent).WalkSpeed = 55
end
end)
Hi! WalkSpeed is a property of Humanoids, which are found in characters not in the players themselves! You need to get the character of the player, or you can just use the TouchedObject instance since you’ve already verified its parent has a Humanoid in it.