I'm very stuck on this script, a little help would be nice! What I'm trying to do is so if the player "Survived" the waves, then they get +1 win on the leaderboard script and if they didn't nothing happens.
Round Script in SSS
local replicatedstorage = game:GetService("ReplicatedStorage") local status = replicatedstorage:WaitForChild("StatusValue") local Players = game.Players local Health = game.Players.Humanoid.Health while true do for i = 15,1,-1 do status.Value = "Intermission: "..i wait(1) end status.Value = "Game in progress" local map = game.ServerStorage.BaseMap map:Clone().Parent = game.Workspace target = CFrame.new(67.98, -47.816, 1156.752) for i, player in ipairs(game.Players:GetChildren()) do player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0) wait(45) if Players.Health 1+ then Wins.Value = +1 target = CFrame.new(37.095, 103.76, 1214.745) for i, player in ipairs(game.Players:GetChildren()) do player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0) game.Workspace.BaseMap:Destroy() status.Value = "Game Over!" end end end
Leaderboard Script :
function CreateStats(NewPlayer) local MainStats = Instance.new("IntValue") MainStats.Name = "leaderstats" MainStats.Value = 0 local PointsValue = Instance.new("IntValue") PointsValue.Name = "Wins" PointsValue.Value = 0 PointsValue.Parent = MainStats MainStats.Parent = NewPlayer return MainStats end game.Players.ChildAdded:connect(CreateStats)
This is my solution, I think it works! Hope you like it!
Okay, Here is the Round Script:
(NOTE: I think the Round Script can be a ServerScript (normal script) and be in workspace and work totally fine!)
local replicatedstorage = game:GetService("ReplicatedStorage") local status = replicatedstorage:WaitForChild("StatusValue") local Players = nil local target = nil while true do for i = 15,1,-1 do status.Value = "Intermission: "..i wait(1) end status.Value = "Game in progress" local map = game.ServerStorage.BaseMap:Clone() map.Parent = workspace target = Vector3.new(67.98, -47.816, 1156.752) Players = game.Players:GetChildren() for i, player in pairs(Players) do player.Character:MoveTo(target + Vector3.new(0, i * 5, 0)) end wait(45) for i, player in pairs(Players) do local Wins = player:FindFirstChild("leaderstats"):FindFirstChild("Wins") if player.Character.Humanoid.Health > 0 then Wins.Value = Wins.Value + 1 end target = Vector3.new(37.095, 103.76, 1214.745) player.Character:MoveTo(target + Vector3.new(0, i * 5, 0)) workspace.BaseMap:Destroy() status.Value = "Game Over!" end end
And here is the LeaderStats script: (NOTE: This script MUST be a LocalScript in StarterPlayer > StarterPlayerScripts in order for it to WORK.)
local LeaderStats = Instance.new("Model", game.Players.LocalPlayer) LeaderStats.Name = "leaderstats" local Wins = Instance.new("IntValue", LeaderStats) Wins.Name = "Wins" Wins.Value = 0
This line is your problem.
if Players.Health 1+ then Wins.Value = +1
Change to this.
if Players.Health > 0 then Wins.Value = Wins.Value + 1
You should look at lua tutorials. It will help you way more than asking for the answer. Programming is repetitive problem solving
@imp here's my progress :
-- Vairbles local replicatedstorage = game:GetService("ReplicatedStorage") local status = replicatedstorage:WaitForChild("StatusValue") local player = game.Players.LocalPlayer local Health = player.Health:FindFirstChild ? local Wins = player.leaderstats.Wins -- Functions while true do for i = 15,1,-1 do status.Value = "Intermission: "..i wait(1) end status.Value = "Game in progress" local map = game.ServerStorage.BaseMap map:Clone().Parent = game.Workspace target = CFrame.new(67.98, -47.816, 1156.752) for i, player in ipairs(game.Players:GetChildren()) do player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0) wait(45) if player.Health > 0 then Wins.Value = Wins.Value + 1 game.Workspace.BaseMap:Destroy() status.Value = "Game Over!" end end end