For some reason whenever I test the multiplier doesn’t start at 1.
here is my script
local = datastorgame:GetService("DataStoreService"):GetDataStore("SpeedSimData")
function onPlayerEntered (player)
local initKey = "user_" .. player.userId .. "_init"
local stepsKey = "user_" .. player.userId .. "_steps"
local multiplierKey = "user_" .. player.userId .. "_multiplier"
local pointsKey = "user_" .. player.userId .. "_point"
local speedKey = "user_" .. player.userId .. "_speed"
local trailKey = "user_" .. player.userId .. "_trail"
if( datastore:GetAsync(initKey)== nil and true)then
datastore:SetAsync(initKey, true)
datastore:SetAsync(stepsKey, 0)
datastore:SetAsync(multiplierKey, 1)
datastore:SetAsync(pointsKey, 0)
datastore:SetAsync(speedKey, 1)
datastore:SetAsync(trailKey, "DefaultTrail")
end
if(datastore:GetAsync(trailKey)== nil) then
datastore:SetAsync(trailKey, "DefaultTrail")
end
local init = datastore:GetAsync(initKey)
local steps = datastore:GetAsync(stepsKey)
local multiplier = datastore:GetAsync(multiplierKey)
local points = datastore:GetAsync(pointsKey)
local speed = datastore:GetAsync(speedKey)
local trail = datastore:GetAsync(trailKey)
--==================================================================
--leaderboard
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local stepsBoard = Instance.new("IntValue")
stepsBoard.Name = "Steps"
stepsBoard.Value = steps
stepsBoard.Parent = leaderstats
local multiplier = Instance.new("IntValue")
multiplier.Name = "Multiplier"
multiplier.Value = multiplier
multiplier.Parent = leaderstats
local speedBoard = Instance.new("IntValue")
speedBoard.Name = "Speed"
speedBoard.Value = speed
speedBoard.Parent = leaderstats
local pointsBoard = Instance.new("IntValue")
pointsBoard.Name = "Points"
pointsBoard.Value = points
pointsBoard.Parent = leaderstats
--===========================
local playerTrail = Instance.new("StringValue")
playerTrail.Name = "PlayerTrail"
playerTrail.Value = trail
playerTrail.Parent = player
local playerIsRacing = Instance.new("BoolValue")
playerIsRacing.Name = "PlayerIsRacing"
playerIsRacing.Value = false
playerIsRacing.Parent = player
local orbGuiInt = Instance.new("IntValue")
orbGuiInt.Name = "StepsBonusCheck"
orbGuiInt.Value = 0
orbGuiInt.Parent = player
local orbGuiBCV = Instance.new("BrickColorValue")
orbGuiBCV.Name = "BCVCheck"
orbGuiBCV.Value = BrickColor.Black()
orbGuiBCV.Parent = player
local serverStorage = game:GetService("ServerStorage")
local mainLoopInstance = serverStorage.MainLoop:Clone()
mainLoopInstance.Name = "MainLoop" .. player.userId
mainLoopInstance.Disabled = false
mainLoopInstance.Parent = game:GetService("ServerScriptService")
player.CharacterAdded:Connect(newCharacter)
end
game.Players.PlayerAdded:Connect(onPlayerEntered)
function onPlayerLeaving (player)
local userId = player.UserId
local leaderstats = player:WaitForChild("leaderstats")
local steps = leaderstats.Steps.Value
local points = leaderstats.Points.Value
local multiplier = player.Multiplier.Value
local speed = leaderstats.Speed.Value
local trail = player.PlayerTrail.Value
local stepsKey = "user_" .. player.userId .. "_steps"
local multiplierKey = "user_" .. player.userId .. "_multiplier"
local pointsKey = "user_" .. player.userId .. "_point"
local speedKey = "user_" .. player.userId .. "_speed"
local trailKey = "user_" .. player.userId .. "_trail"
datastore:SetAsync(stepsKey, steps)
datastore:SetAsync(pointsKey, points)
datastore:SetAsync(speedKey, speed)
datastore:SetAsync(multiplierKey, multiplier)
datastore:SetAsync(trailKey, trail)
end
game.Players.PlayerRemoving:Connect(onPlayerLeaving)
function newCharacter(character)
local player = game.Players:GetPlayerFromCharacter(character)
local trail = player.PlayerTrail.Value
local speed = player.leaderstats.Speed.Value
local humanoid = character:WaitForChild("Humanoid")
game:GetService("RunService").Stepped:wait()
local storedTrail = game.ReplicatedStorage[trail]
local playerTrail = storedTrail:Clone()
playerTrail.Parent = character.HumanoidRootPart
if character:FindFirstChild("UpperTorso") then
playerTrail.Attachment0 = character.Head.FaceFrontAttachment
playerTrail.Attachment1 = character.UpperTorso.WaistRigAttachment
else
playerTrail.Attachment0 = character.Head.FaceFrontAttachment
playerTrail.Attachment1 = character.HumanoidRootPart.RootRigAttachment
end
humanoid.WalkSpeed = speed
humanoid.JumpPower = speed*.75
end