Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't this change someone's walkspeed?

Asked by
Retroc 35
9 years ago

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

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

"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!

Ad

Answer this question