My apologies, I did not explain that correctly. Let me start again.
I am trying to make a training course where if you step on a pad, it starts the training round.
Script for the pad:
local isReady = true
function onTouch(part)
local character = part.Parent
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid then
local player = game.Players:GetPlayerFromCharacter(character)
player.TouchedStart.Value = true
script.Parent.Parent.SpawnPlayerScript.Yes:Fire()
end
end
script.Parent.Touched:Connect(onTouch)
and when it starts, this is the training round runner:
local head = script.Parent.Head
local goTo = script.Parent.GotoBrick
local goBack = script.Parent.GobackBrick
local StartingTimer = script.Parent.TimeStart.SurfaceGui.TextLabel
local RoundTimer1 = script.Parent.TIME1.SurfaceGui.TextLabel
local RoundTimer2 = script.Parent.TIME2.SurfaceGui.TextLabel
local RoundTimer3 = script.Parent.TIME3.SurfaceGui.TextLabel
local RoundTimer4 = script.Parent.TIME4.SurfaceGui.TextLabel
local somePlayers = false
math.randomseed(tick())
local roundInProgress = false
function Yes()
if roundInProgress == false then
roundInProgress = true
for i = 15, 0, -1 do
StartingTimer.Text = ("Training Round starts in..." .. i)
wait(1)
end
StartingTimer.Text = ("Training Round in progress")
local cacaClone = game.ServerStorage.TrainingAIs["Training Ax AI"]:Clone()
local cacaClone2 = game.ServerStorage.TrainingAIs["Training Knife AI"]:Clone()
local cacaClone3 = game.ServerStorage.TrainingAIs["Training Sword AI"]:Clone()
cacaClone.Parent = workspace.AIsInTraining
cacaClone2.Parent = workspace.AIsInTraining
cacaClone3.Parent = workspace.AIsInTraining
head.CFrame = goTo.CFrame
for i, player in ipairs(game.Players:GetPlayers()) do
if player.TouchedStart.Value == true then
local whichSpawn = script.Parent.WhichSpawn:GetChildren()
local teleLoc = math.random(1, #whichSpawn)
local cheesy = whichSpawn[teleLoc]
player.Character.HumanoidRootPart.CFrame = cheesy.CFrame
local whichWeapon = game.ServerStorage.TrainingWeapons:GetChildren()
local weaponNumber = math.random(1, #whichWeapon)
local funky = whichWeapon[weaponNumber]:Clone()
funky.Parent = player:WaitForChild("Backpack")
script.Parent.PlayerCount.Value = script.Parent.PlayerCount.Value + 1
end
end
for i = 90, 0, -1 do
if script.Parent.PlayerCount.Value ~= 0 then
RoundTimer1.Text = ("TIME:"..i)
RoundTimer2.Text = ("TIME:"..i)
RoundTimer3.Text = ("TIME:"..i)
RoundTimer4.Text = ("TIME:"..i)
wait(1)
end
if script.Parent.PlayerCount.Value == 0 then
RoundTimer1.Text = ("Training Round Has Not Started")
RoundTimer2.Text = ("Training Round Has Not Started")
RoundTimer3.Text = ("Training Round Has Not Started")
RoundTimer4.Text = ("Training Round Has Not Started")
StartingTimer.Text = ("Training Round Has Not Started")
end
end
RoundTimer1.Text = ("Training Round Has Not Started")
RoundTimer2.Text = ("Training Round Has Not Started")
RoundTimer3.Text = ("Training Round Has Not Started")
RoundTimer4.Text = ("Training Round Has Not Started")
StartingTimer.Text = ("Training Round Has Not Started")
for i, player in ipairs(game.Players:GetPlayers()) do
if player.TouchedStart.Value == true then
player.TouchedStart.Value = false
player:LoadCharacter()
script.Parent.PlayerCount.Value = script.Parent.PlayerCount.Value - 1
end
end
for i, AI in ipairs(game.Workspace.AIsInTraining:GetChildren()) do
AI:Destroy()
end
head.CFrame = goBack.CFrame
roundInProgress = false
end
end
script.Yes.Event:Connect(Yes)
function No()
for i, player in ipairs(game.Players:GetPlayers()) do
if player.TouchedStart.Value == true then
player:LoadCharacter()
player.TouchedStart.Value = false
end
end
end
script.No.Event:Connect(No)
as you can see, I when they join the training round the int value is added by 1, and when they die or finish it is decreased by 1. Everything about that works, except for when players die. And I have this bit of code in my main game runner.
--add player function that keeps track of current players
function addPlayer(player)
local playing = Instance.new("BoolValue", player)
playing.Value = false
playing.Name = "Playing"
local hasHammer = Instance.new("BoolValue", player)
hasHammer.Name = 'HasHammer'
hasHammer.Value = false
local refund = Instance.new("IntValue", player)
refund.Name = 'Refund'
refund.Value = 0
local hasLauncher = Instance.new("BoolValue", player)
hasLauncher.Name = 'HasLauncher'
hasLauncher.Value = false
local hasGunJeep = Instance.new("BoolValue", player)
hasGunJeep.Name = 'HasGunJeep'
hasGunJeep.Value = false
local hasOrb = Instance.new("BoolValue", player)
hasOrb.Name = 'HasOrb'
hasOrb.Value = false
local hasSneak = Instance.new("BoolValue", player)
hasSneak.Name = 'HasSneak'
hasSneak.Value = false
local hasMeleeJeep = Instance.new("BoolValue", player)
hasMeleeJeep.Name = 'HasMeleeJeep'
hasMeleeJeep.Value = false
local hasTankJeep = Instance.new("BoolValue", player)
hasTankJeep.Name = 'HasTankJeep'
hasTankJeep.Value = false
local hasSpear = Instance.new("BoolValue", player)
hasSpear.Name = 'HasSpear'
hasSpear.Value = false
local notkillable = Instance.new("BoolValue", player)
notkillable.Name = 'Notkillable'
notkillable.Value = false
local hasNuke = Instance.new("BoolValue", player)
hasNuke.Name = 'HasNuke'
hasNuke.Value = false
local hasCrossbow = Instance.new("BoolValue", player)
hasCrossbow.Name = 'HasCrossbow'
hasCrossbow.Value = false
local hasStaff = Instance.new("BoolValue", player)
hasStaff.Name = 'HasStaff'
hasStaff.Value = false
local hasMace = Instance.new("BoolValue", player)
hasMace.Name = 'HasMace'
hasMace.Value = false
local hasMini = Instance.new("BoolValue", player)
hasMini.Name = 'HasMini'
hasMini.Value = false
local giveOrb = Instance.new("BoolValue", player)
giveOrb.Name = 'GiveOrb'
giveOrb.Value = false
local giveJeep = Instance.new("BoolValue", player)
giveJeep.Name = 'GiveJeep'
giveJeep.Value = false
local nukePro = Instance.new("BoolValue", player)
nukePro.Name = 'NukePro'
nukePro.Value = false
local VoteMap = Instance.new("BoolValue", player)
VoteMap.Name = 'VoteMap'
VoteMap.Value = false
local touchedStart = Instance.new("BoolValue", player)
touchedStart.Name = 'TouchedStart'
touchedStart.Value = false
wait(5)
if player.leaderstats.POINTS.Value > 9 then
player.leaderstats.LEVEL.Value = 2
end
if player.leaderstats.POINTS.Value > 19 then
player.leaderstats.LEVEL.Value = 3
end
if player.leaderstats.POINTS.Value > 29 then
player.leaderstats.LEVEL.Value = 4
end
if player.leaderstats.POINTS.Value > 39 then
player.leaderstats.LEVEL.Value = 5
player.HasCrossbow.Value = true
end
if player.leaderstats.POINTS.Value > 49 then
player.leaderstats.LEVEL.Value = 6
end
if player.leaderstats.POINTS.Value > 59 then
player.leaderstats.LEVEL.Value = 7
end
if player.leaderstats.POINTS.Value > 69 then
player.leaderstats.LEVEL.Value = 8
end
if player.leaderstats.POINTS.Value > 79 then
player.leaderstats.LEVEL.Value = 9
end
if player.leaderstats.POINTS.Value > 89 then
player.leaderstats.LEVEL.Value = 10
end
if player.leaderstats.POINTS.Value > 99 then
player.leaderstats.LEVEL.Value = 11
end
if player.leaderstats.POINTS.Value > 109 then
player.leaderstats.LEVEL.Value = 12
player.HasStaff.Value = true
end
if player.leaderstats.POINTS.Value > 119 then
player.leaderstats.LEVEL.Value = 13
end
if player.leaderstats.POINTS.Value > 129 then
player.leaderstats.LEVEL.Value = 14
end
if player.leaderstats.POINTS.Value > 139 then
player.leaderstats.LEVEL.Value = 15
end
if player.leaderstats.POINTS.Value > 149 then
player.leaderstats.LEVEL.Value = 16
end
if player.leaderstats.POINTS.Value > 159 then
player.leaderstats.LEVEL.Value = 17
end
if player.leaderstats.POINTS.Value > 169 then
player.leaderstats.LEVEL.Value = 18
end
if player.leaderstats.POINTS.Value > 179 then
player.leaderstats.LEVEL.Value = 19
end
if player.leaderstats.POINTS.Value > 189 then
player.leaderstats.LEVEL.Value = 20
player.HasTankJeep.Value = true
end
if player.leaderstats.POINTS.Value > 199 then
player.leaderstats.LEVEL.Value = 21
end
if player.leaderstats.POINTS.Value > 209 then
player.leaderstats.LEVEL.Value = 22
end
if player.leaderstats.POINTS.Value > 219 then
player.leaderstats.LEVEL.Value = 23
end
if player.leaderstats.POINTS.Value > 229 then
player.leaderstats.LEVEL.Value = 24
end
if player.leaderstats.POINTS.Value > 239 then
player.leaderstats.LEVEL.Value = 25
end
--remove character funciton that removes active players when they die or leave
local function removeCharacter()
if(player.Playing.Value == true) then
if modeTeam == true then
if player.Team == game.Teams["Red Team"] then
aliveRedPlayers = aliveRedPlayers - 1
alivePlayers = alivePlayers - 1
player.Playing.Value = false
player.leaderstats.CASH.Value = player.leaderstats.CASH.Value + 25
Announce(player.Name .." Died")
end
if player.Team == game.Teams["Blue Team"] then
aliveBluePlayers = aliveBluePlayers - 1
alivePlayers = alivePlayers - 1
player.Playing.Value = false
player.leaderstats.CASH.Value = player.leaderstats.CASH.Value + 25
Announce(player.Name .." Died")
end
end
if modeNormal == true or modeNPW == true or modeAi == true or modeNWP == true then
alivePlayers = alivePlayers - 1
player.Playing.Value = false
player.leaderstats.CASH.Value = player.leaderstats.CASH.Value + 25
Announce(player.Name .." Died")
end
end
end
if player.TouchedStart.Value == true then
game.Workspace.SpawnBase.Barracks["Start Training"].PlayerCount.Value = game.Workspace.SpawnBase.Barracks["Start Training"].PlayerCount.Value - 1
player.TouchedStart.Value = false
end
player.CharacterRemoving:Connect(removeCharacter)
end
game:GetService("Players").PlayerAdded:Connect(addPlayer)
don’t worry about all the extra instances and stuff, what I am trying to figure out is why this:
if player.TouchedStart.Value == true then
game.Workspace.SpawnBase.Barracks["Start Training"].PlayerCount.Value = game.Workspace.SpawnBase.Barracks["Start Training"].PlayerCount.Value - 1
player.TouchedStart.Value = false
end
line of code won’t run when someone dies.
I am getting no errors what so ever.
and I can’t figure out why it won’t run.
Sorry my first post wasn’t very clear, I am kinda new at tthis.
oh by the way thanks for telling me about the instance thing, that was helpful