My script isn't working. I'm trying to make a medieval battle game and i have an intvalue inside the player character called "Horses". I want to make it increase the speed if you have more horses. I've tried putting it in startercharacterscripts, replicatedfirst, and serverscriptservice. Here is the code:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local horses = character:WaitForChild("Horses").Value
horses.Changed:Connect(function()
character:FindFirstChild("Humanoid").Walkspeed = 5
if horses > 0 then
character:FindFirstChild("Humanoid").WalkSpeed = character:FindFirstChild("Humanoid").WalkSpeed + horses * 0.35
end
end)

1 comment
Is it erroring? Also I would put if horses.Value > 0 and just local horses = character:WaitForChild("Horses").