Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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

01local replicatedstorage = game:GetService("ReplicatedStorage")
02local status = replicatedstorage:WaitForChild("StatusValue")
03local Players = game.Players
04local Health = game.Players.Humanoid.Health
05 
06while true do
07for i = 15,1,-1 do
08status.Value = "Intermission: "..i
09wait(1)
10end
11status.Value = "Game in progress"
12local map = game.ServerStorage.BaseMap
13map:Clone().Parent = game.Workspace
14target = CFrame.new(67.98, -47.816, 1156.752)
15for i, player in ipairs(game.Players:GetChildren()) do
View all 30 lines...

Leaderboard Script :

01function CreateStats(NewPlayer)
02    local MainStats = Instance.new("IntValue")
03    MainStats.Name = "leaderstats"
04    MainStats.Value = 0
05    local PointsValue = Instance.new("IntValue")
06    PointsValue.Name = "Wins"
07    PointsValue.Value = 0
08    PointsValue.Parent = MainStats
09    MainStats.Parent = NewPlayer
10    return MainStats
11end
12 
13game.Players.ChildAdded:connect(CreateStats)
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 NodaDuck45 15 — 7y
0
Can you give me an example? I'm new to humanoid stuff. devconstruct 4 — 7y
0
CAN SOMEONE JUST EDIT THE SCRIPT AND REPOST IT PLEASE? devconstruct 4 — 7y
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 zanyder 1 — 7y

3 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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!)

01local replicatedstorage = game:GetService("ReplicatedStorage")
02local status = replicatedstorage:WaitForChild("StatusValue")
03local Players = nil
04local target = nil
05 
06while true do
07    for i = 15,1,-1 do
08        status.Value = "Intermission: "..i
09        wait(1)
10    end
11    status.Value = "Game in progress"
12 
13    local map = game.ServerStorage.BaseMap:Clone()
14    map.Parent = workspace
15 
View all 40 lines...

And here is the LeaderStats script: (NOTE: This script MUST be a LocalScript in StarterPlayer > StarterPlayerScripts in order for it to WORK.)

1local LeaderStats = Instance.new("Model", game.Players.LocalPlayer)
2LeaderStats.Name = "leaderstats"
3 
4local Wins = Instance.new("IntValue", LeaderStats)
5Wins.Name = "Wins"
6Wins.Value = 0
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

This line is your problem.

1if Players.Health 1+ then Wins.Value = +1

Change to this.

1if 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

0
"Wins" is unknown, how can I connect the two scripts? devconstruct 4 — 7y
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 devconstruct 4 — 7y
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. Impacthills 223 — 7y
0
Looks like your Wins object will be at 'player.leaderstats.Wins' you can figure the rest out. Impacthills 223 — 7y
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

@imp here's my progress :

01-- Vairbles
02local replicatedstorage = game:GetService("ReplicatedStorage")
03local status = replicatedstorage:WaitForChild("StatusValue")
04local player = game.Players.LocalPlayer
05local Health = player.Health:FindFirstChild ?
06local Wins = player.leaderstats.Wins
07 
08-- Functions
09while true do
10for i = 15,1,-1 do
11status.Value = "Intermission: "..i
12wait(1)
13end
14status.Value = "Game in progress"
15local map = game.ServerStorage.BaseMap
View all 28 lines...
0
Only problem, "local Health = player.Health:FindFirstChild ?" can anyone help? devconstruct 4 — 7y

Answer this question