I have been trying to make this script but I just can't.The walkspeed does not change. Please explain and show me the script.
I am going to assume you have already made a DataStore that gives each player their "Wins". But if you didn't, first type this into a server script (It's not a DataStore, just something that shows a players wins, basically it won't save the players wins):
game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local wins = Instance.new("IntValue") wins.Name = "Wins" wins.Parent = leaderstats end)
After you are done with that, insert a LOCAL script into StarterPlayerScripts. You should find it under StarterPlayer. After you insert that, do this, assuming each player is going to get one win at a time:
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local wins = player.leaderstats.Wins -- Change Wins to whatever you named the IntValue local value = 10 -- Put whatever number you want wins.Changed:Connect(function() humanoid.WalkSpeed = humanoid.WalkSpeed + value --Or multiply, depending on how intense you want it to be end)
This is a very simple way to do it. How you reward players' a win is up to you, but the local script should be able to detect that the player gained a win. If you're looking for something a bit more complex than this, let me know.
You can use loop to set the walkspeed of the player equal to their wins value, here is the example! Must be a local script
local plr = game.Players.LocalPlayer while wait() do local char = plr.Character or plr.CharacterAdded:Wait() char.Humanoid.WalkSpeed = (plr.leaderstats.Wins.Value) + 16 -- If player wins is 0, the game will still set the player to their normal speed! end
You can get more resource here :
Goodluck!
( If the link didnt showing up, try this : http://developer.roblox.com/en-us/articles/Loops )