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

if Players.Health 1+ then Wins.Value = +1 isn't working?

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)

4 comments

0

Well, I think you've got your health stuff wrong, I believe you need to get the players character, then its humanoid, and then just check if humanoid.Health > 0

0

Can you give me an example? I'm new to humanoid stuff.

0

CAN SOMEONE JUST EDIT THE SCRIPT AND REPOST IT PLEASE?

0

Even if you fixed the script as intended, players who respawn and still have health > 1 will get a point. I'd recommend first creating a flag to mark dead players and then make the system just reward anyone who isn't marked by the time the waves end

3 answers

✓ Accepted answer

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

4 comments

0

"Wins" is unknown, how can I connect the two scripts?

0

And also another problem, they shouldn't get a win if there in the lobby, they need to be in the base map to get a win, e.e

0

Wins isn't a script.. It's an object with a data type of Int. You meed to create a referencek to where you have your Wins object. Sorry I cannot spoon feed. This isn't a request forum.

0

Looks like your Wins object will be at 'player.leaderstats.Wins' you can figure the rest out.

@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

1 comment

0

Only problem, "local Health = player.Health:FindFirstChild ?" can anyone help?

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