When I was typing I thought it was completely simple, but when I looked at it as I got the error I just couldn't figure out. I just thought I would put Speed.Value as game.Players.LocalPlayers.Character.Humanoid.WalkSpeed. Any way this is what I had.
game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local plr = game.Players.LocalPlayer.Character.Humanoid local speed = Instance.new("NumberValue") speed.Name = "Speed" speed.Parent = leaderstats speed.Value = plr.WalkSpeed end)
Instead of checking for the walkspeed in the player you want to check the humanoids walkspeed. Use player.Character.Humanoid.WalkSpeed
to start it off then in another script that you put inside the players character (By placing it in game.StarterPlayer.StarterCharacterScripts) with this code:
while wait() do local Char = script.Parent local Humanoid = Char:WaitForChild("Humanoid") local player = game.Players:GetPlayerFromCharacter(Char) if player then --Just to make sure local stats = player:WaitForChild("leaderstats") local speed = stats:WaitForChild("Speed") speed.Value = Humanoid.WalkSpeed end end
Remember to put that in a server script not a local script
Could you do... (LeaderStats is your script)
speed.Value = game:FindFirstChild("LeaderStats")
Well in this case follow these steps.
1) Make sure that your leaderstats script only has the variables such as speed. As I see up there you have used LocalPlayer which wont work in normal scripts.
2) Just delete those and make a normal leaderstats script with speed or the things you want.
3) Insert a local script in starter player > starter character scripts.
4) In that local script type in the following.
while wait(1) do local plr = game.Players.LocalPlayer local speed = plr.leaderstats.Speed speed.Value = script.Parent:FindFirstChild("Humanoid").WalkSpeed end
OR if you want to make the opposite. (Leaderstats = character speed) then follow this code
while wait(1) do local plr = game.Players.LocalPlayer local speed = plr.leaderstats.Speed script.Parent:FindFirstChild("Humanoid").WalkSpeed = speed.Value end