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

Player walkspeed not changing when calling function with CharacterAdded?

Asked by 5 years ago
Edited 5 years ago
local speed = game.Workspace.WorkspaceScripts.Weather2.walkspeed
local player = game.Players.LocalPlayer
local character = player.Character 
while not character or not character.Parent do
    character = player.Character
    wait()
end

speed.Changed:Connect(function()
    character.Humanoid.WalkSpeed=speed.Value
end)

player.CharacterAdded:Connect(function()
    character.Humanoid.WalkSpeed = speed.Value
end)

Both functions do run, the one on top works fine but the 2nd one doesn't seem to change my walkspeed. Im not getting any errors in the output.

1 answer

Log in to vote
0
Answered by 5 years ago

Alright well I guess I figured it out. I just had to wait for my character before trying to change it's speed.

local speed = game.Workspace.WorkspaceScripts.Weather2.walkspeed
local player = game.Players.LocalPlayer
local character = player.Character 
while not character or not character.Parent do
    character = player.Character
    wait()
end

speed.Changed:Connect(function()
    character.Humanoid.WalkSpeed=speed.Value
end)

player.CharacterAdded:Connect(function()
    while not character or not character.Parent do
        character = player.Character
        wait()
    end
    character.Humanoid.WalkSpeed = speed.Value
end)

Ad

Answer this question