Hello! In January, I created this code that gives players XP, and points depending on how much time they got.
if not won then
won = true
local trialTime = game:GetService("ReplicatedStorage"):WaitForChild("TimeTrials")
if trialTime.Value < plr.TimeTrials[name].Value or plr.TimeTrials[name].Value == 0 then
game:GetService("ReplicatedStorage").Music:FireClient(plr, "Win")
plr.TimeTrials:FindFirstChild(name).Value = trialTime.Value
plr.PlayerGui.EndScreen.Trials.Improve.Text = "Your improved your time!"
else
game:GetService("ReplicatedStorage").Music:FireClient(plr, "Lose")
plr.PlayerGui.EndScreen.Trials.Improve.Text = "You did not improve your time. "
end
plr.PlayerGui.EndScreen.Trials.NewTime.Text = "Your time was ".. formatTime(trialTime.Value).. ". "
if trialTime.Value < game.ServerStorage.Rewards[name].Gold:GetAttribute("Time") then
plr:WaitForChild("leaderstats"):WaitForChild("Points").Value += game.ServerStorage.Rewards[name].Gold:GetAttribute("Points")
plr:WaitForChild("LevelsSystem"):WaitForChild("Current").Value += game.ServerStorage.Rewards[name].Gold:GetAttribute("XP")
plr.PlayerGui.EndScreen.Trials.Tier.Text = "You won Gold Tier!"
plr.PlayerGui.EndScreen.Trials.Tier.TextColor3 = Color3.fromRGB(255, 196, 57)
game:GetService("ReplicatedStorage").SendPoints:FireClient(plr, game.ServerStorage.Rewards[name].Gold:GetAttribute("Points"))
game:GetService("ReplicatedStorage").SendXP:FireClient(plr, game.ServerStorage.Rewards[name].Gold:GetAttribute("XP"))
badgeser:AwardBadge(plr.UserId, 2124624904)
if mps:UserOwnsGamePassAsync(plr.UserId, 12460579) then
plr.leaderstats.Points += game.ServerStorage.Rewards[name].Gold:GetAttribute("Points")
end
elseif trialTime.Value > game.ServerStorage.Rewards[name].Bronze:GetAttribute("Time") then
plr:WaitForChild("leaderstats"):WaitForChild("Points").Value += game.ServerStorage.Rewards[name].Bronze:GetAttribute("Points")
plr:WaitForChild("LevelsSystem"):WaitForChild("Current").Value += game.ServerStorage.Rewards[name].Bronze:GetAttribute("XP")
plr.PlayerGui.EndScreen.Trials.Tier.Text = "You won Bronze Tier!"
plr.PlayerGui.EndScreen.Trials.Tier.TextColor3 = Color3.fromRGB(95, 73, 21)
game:GetService("ReplicatedStorage").SendPoints:FireClient(plr, game.ServerStorage.Rewards[name].Bronze:GetAttribute("Points"))
game:GetService("ReplicatedStorage").SendXP:FireClient(plr, game.ServerStorage.Rewards[name].Bronze:GetAttribute("XP"))
badgeser:AwardBadge(plr.UserId, 2124624907)
if mps:UserOwnsGamePassAsync(plr.UserId, 12460579) then
plr.leaderstats.Points += game.ServerStorage.Rewards[name].Bronze:GetAttribute("Points")
end
else
plr:WaitForChild("leaderstats"):WaitForChild("Points").Value += game.ServerStorage.Rewards[name].Silver:GetAttribute("Points")
plr:WaitForChild("LevelsSystem"):WaitForChild("Current").Value += game.ServerStorage.Rewards[name].Silver:GetAttribute("XP")
plr.PlayerGui.EndScreen.Trials.Tier.Text = "You won Silver Tier!"
plr.PlayerGui.EndScreen.Trials.Tier.TextColor3 = Color3.fromRGB(112, 112, 112)
game:GetService("ReplicatedStorage").SendPoints:FireClient(plr, game.ServerStorage.Rewards[name].Silver:GetAttribute("Points"))
game:GetService("ReplicatedStorage").SendXP:FireClient(plr, game.ServerStorage.Rewards[name].Silver:GetAttribute("XP"))
badgeser:AwardBadge(plr.UserId, 2124624905)
if mps:UserOwnsGamePassAsync(plr.UserId, 12460579) then
plr.leaderstats.Points += game.ServerStorage.Rewards[name].Silver:GetAttribute("Points")
end
end
end
However, this code looks clunky, hard to read, and may be unreliable. If you can help improve it, please let me know. Thanks! WE