Hello there! I have a thing where i want to set the player's WalkSpeed to the one defined in the leaderstats. Any help is appreciated, Thanks in advance!
LocalScript:
wait(5)
local players = game.Players
local plr = players.LocalPlayer
local plrName = plr.Name
local leaderstats = players:FindFirstChild(plrName).leaderstats
local h = game.Workspace:FindFirstChild(plrName).Humanoid
local VectorZero = Vector3.new(0, 0, 0)
local function Moved()
if h.MoveDirection ~= VectorZero then
leaderstats.Speed = leaderstats.Speed + 1
else
print("Stopped Moving")
end
end
h:GetPropertyChangedSignal("MoveDirection"):Connect(Moved)
while true do
wait()
h.WalkSpeed = leaderstats.Speed / 10
end
Leaderboard script:
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Value = 0
cash.Parent = leaderstats
local speed = Instance.new("IntValue")
speed.Name = "Speed"
speed.Value = 1
speed.Parent = leaderstats
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
Explorer:
Error:
22:52:07.425 - Players.EiOooAxea.PlayerScripts.LocalScript:24: attempt to perform arithmetic (div) on userdata and number

2 comments
Can you put your code into code blocks
yea sorry idk what happened it didnt put them