Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't this change someone's walkspeed?

I have a script here. Everything works except line 13. Walkspeed doesn't change. Doesn't say anything in Output. Thanks!

Teleport = game.Workspace.Teleport
Location = game.Workspace.Teleport.Position

function GiveSword(Part)
	Char = Part.Parent
	print(Char)
	if game.Players:GetPlayerFromCharacter(Part.Parent) ~=nil then
	   script.Disabled = true
	   Player = game.Players:GetPlayerFromCharacter(Part.Parent)	
	   Sword = game.Lighting.Sword:Clone()
	   Sword.Parent = Player.Backpack
	   Char:MoveTo(Vector3.new(Location))
	   Char.Humanoid.Walkspeed = 16
	   wait(0.25)
	   script.Disabled = false
	end
end


script.Parent.Touched:connect(GiveSword)

1 answer

✓ Accepted answer

"Walkspeed is not a valid member of Humanoid" or something like it should have shown up in the Output. But anyways, it's not Walkspeed. It's WalkSpeed.

So,

Char.Humanoid.WalkSpeed = 16

I would also recommend use local variables as much as possible, as it will decrease lag.

And since you have Part.Parent defined in a variable, why do

game.Players:GetPlayerFromCharacter(Part.Parent)

instead of

game.Players:GetPlayerFromCharacter(Char)

?

Hope i helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.