Hey this is my first post. Im new at proggraming and i ran into a problem that i cant find a solution for.
-
What do you want to achieve? Keep it simple and clear!
I am making a small game where two random players from the players in the sever being chosen and being teleported to the map. The map changes every round. The goal for the players is the press the button, the first player who presses the button will get 10 points and the players will return toe the lobby. -
What is the issue?
The issue is that when a player presses the button he doesn’t get any points. I don’t get any errors. -
What solutions have you tried so far?
I’ve looked in the developer forum and many different tutorials and could not find an answer.
Help would be much appriciated!
Here is the system script:
Players = game:GetService("Players")
Teams = game:GetService("Teams")
local SpectateTeam = game.Teams.Spectate
local ItTeam = game.Teams.Blue
local RunnerTeam = game.Teams.Red
local roundlength = 8
local intermissionLength = 4
local inRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local LobbySpawn = workspace.Map.SpawnLobby
local MapSpawnIt = workspace.Map.SpawnMapIt
local MapSpawnRunner = workspace.Map.SpawnMapRunner
local frame = game.StarterGui.ScreenGuimenu.Frame
local KillerSpawn = workspace.Map.SpawnMapIt
local lobbyspace = workspace.Lobbyspace
local SurvivedPoints = 10
local time = 3
game.Players.PlayerAdded:Connect(function(player)
player.Team = SpectateTeam
end)
local function Cancollide() -- release players when round begins
MapSpawnRunner.CanCollide = false
MapSpawnIt.CanCollide = false
wait(1)
MapSpawnRunner.CanCollide = true
MapSpawnIt.CanCollide = true
end
inRound.Changed:Connect(function(player)
if inRound.Value == true then
local chosen = Players:GetChildren()[math.random(1, #Players:GetChildren())]
print(chosen)
chosen.Team = ItTeam
local runnerTeam = Teams.Spectate:GetPlayers()
local runner = runnerTeam[math.random(1,#runnerTeam)]
print(runner)
runner.Team = RunnerTeam
wait()
runner.Character.HumanoidRootPart.CFrame = MapSpawnRunner.CFrame
chosen.Character.HumanoidRootPart.CFrame = KillerSpawn.CFrame
local Obbys = game.ReplicatedStorage.Obbys
local chosenobby = Obbys:GetChildren()[math.random(1,#Obbys:GetChildren())]
print(chosenobby)
local Copy = chosenobby:Clone()
Copy.Parent = workspace.Map.ObbyFolder
local Buttonred = Copy.ButtonRed.Button:WaitForChild("ClickDetector")
local Buttonblue = Copy.ButtonBlue.Button:WaitForChild("ClickDetector")
Buttonred.MouseClick:Connect(function()
inRound.Value = false
Copy:Destroy()
end)
Buttonblue.MouseClick:Connect(function()
inRound.Value = false
Copy:Destroy()
end)
end
if inRound.Value == false then
for _, player in pairs(game.Players:GetChildren(player)) do
local char = player.Character
char.HumanoidRootPart.CFrame = LobbySpawn.CFrame
player.Team = SpectateTeam
if workspace.Map.ObbyFolder:GetChildren() then
workspace.Map.ObbyFolder:ClearAllChildren()
end
end
end
end)
local function RoundTimer()
while wait() do
for i = intermissionLength, 0, -1 do
inRound.Value = false
wait(1)
Status.Value = "Intermission:" .. i .."seconds left!"
end
if #Players:GetPlayers() >= 2 then
wait(1)
inRound.Value = true
Status.Value= "Ready?"
for b = time, 0, -1 do
wait(1)
Status.Value = b
end
Cancollide()
for i = roundlength, 0, -1 do
wait()
Status.Value = i.." seconds left!"
wait(1)
end
else
for i = intermissionLength, 0, -1 do
inRound.Value = false
wait(1)
Status.Value = "Intermission:" .. i .."seconds left!"
end
end
end
end
spawn(RoundTimer())