this script is supposed to change the player’s walkspeed to the value of speed, but it just keeps setting it to whatever the initial value is. I’ve tried asking chat GPT, and i couldnt find anything anywhere.
my script:
local RunService = game:GetService("RunService")
local speed = game.StarterPlayer.StarterCharacterScripts.SpeedSetter.Speed
local function updateWalkspeed()
for _, player in pairs(Players:GetPlayers()) do
local character = player.Character
if character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.WalkSpeed = speed.Value
end
end
end
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
updateWalkspeed()
end)
end)
Players.PlayerRemoving:Connect(function(player)
end)
RunService.Heartbeat:Connect(function()
updateWalkspeed()
end)
speed.Changed:Connect(function()
updateWalkspeed()
end)
Im currently getting the attempt to index nil with ‘Humanoid’ error on line 13
local RunService = game:GetService("RunService")
local speed = script.Speed
speed.Changed:Connect(function()
for _,plr in game.Players:GetChildren() do
plr.Character.Humanoid.WalkSpeed = speed.Value
end
end)
game.Players.PlayerAdded:Connect(function(player)
player.Character.Humanoid.WalkSpeed = speed.Value
end)