Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

explain the script to make a speeddatastore so that players who rejoin can get their speed back?

I have made a speed change script

local player = game.Players.LocalPlayer 
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid") local wins = player.leaderstats.Wins 
local value = 10
wins.Changed:Connect(function() humanoid.WalkSpeed = humanoid.WalkSpeed + value end)

1 answer

✓ Accepted answer

LocalScript (ClientScript)

local player = game.Players.LocalPlayer 
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local wins = player.leaderstats.Wins 
local value = 10

wins:GetPropertyChangedSignal('Value'):Connect(function()
	humanoid.WalkSpeed = humanoid.WalkSpeed + (value * wins.Value) / 2
end)

ServerScript (Script)

--< Services
local PlayerService = game:GetService('Players')
local RStorageService = game:GetService('ReplicatedStorage')
local DataStoreService = game:GetService('DataStoreService')

--< Variables
local DataStore = DataStoreService:GetDataStore('Datas')

--< Events
PlayerService.PlayerAdded:Connect(function(player)
	local l = Instance.new('Folder', player)
	l.Name = 'leaderstats'
	local w = Instance.new('IntValue', l)
	w.Name = 'Wins'
	w.Value = DataStore:GetAsync(player.UserId) or 0
end)

PlayerService.PlayerRemoving:Connect(function(player)
	if player:FindFirstChild('leaderstats') then
		DataStore:SetAsync(player.UserId, player.leaderstats.Wins.Value)
	end
end)

Hope this help, to more questions put bellow in commentaries.

This discussion is preserved as it was. New answers, comments, and votes are closed.