So i made a round system but i have a feature in game that allows players to fix generators and reduce the round time by 45 Seconds but the thing is i would have to communicate to the server and that is killing me as i am intermediate at this can someone tell me how to fix this!
SERVER SCRIPT
local ROUND_TIME = 200
local INTERMISSION = 3
local KillerChooseTime = 3
local KillerSpawnTime = 7
local DoorCloseTime = 10local inRound = game:GetService(“ReplicatedStorage”).InRound
local Staus = game:GetService(“ReplicatedStorage”).Statuslocal KillerTeam = game.Teams.Killer
local Survivor = game.Teams.Survivor
local Lobby = game.Teams.Lobby
local KillerSpawn = workspace.KillerSpawn
local FixGenerator = game.ReplicatedStorage.FixGeneratorlocal Gates = workspace.Gates
FixGenerator.OnServerEvent:Connect(function(player,Generator1,ColorChange)
ROUND_TIME -= 100
Generator1.Lights1.BrickColor = ColorChange
Generator1.Lights2.BrickColor = ColorChange
print(ROUND_TIME)end)
inRound.Changed:Connect(function()
if inRound.Value == true then
for i, plr in pairs(game.Players:GetChildren()) do local Char = plr.Character or plr.CharacterAdded:Wait() local HumRP = Char:WaitForChild("HumanoidRootPart") if plr.Team == Lobby then HumRP.CFrame = workspace.MapSpawn.CFrame plr.Team = Survivor elseif plr.Team == KillerTeam then return end Char:WaitForChild("Humanoid").Died:Connect(function() plr.Team = Lobby end) end
else
for i, plr in pairs(game.Players:GetChildren()) do local char = plr.Character local HumRP = char:WaitForChild("HumanoidRootPart") HumRP.CFrame = game.Workspace.LobbySpawn.CFrame plr.Team = Lobby end
end
end)local function Round()
while true doinRound.Value = false for i = INTERMISSION, 0, -1 do Staus.Value = "Round Begins in "..i wait(1) end for i = KillerChooseTime, 0, -1 do Staus.Value = "Choosing Killer!" wait(1) end local Player = game.Players:GetPlayers() for i = 1, #Player do local ChosenPlayer = Player[math.random(i)] local Killers = {} ChosenPlayer.Team = KillerTeam for i, plr in pairs(game.Players:GetChildren()) do if plr.Team.Name == "Killer" then table.insert(Killers, ChosenPlayer.Name) end end wait(1) end inRound.Value = true for i = KillerSpawnTime, 0, -1 do Staus.Value = "Killer Will Spawn in "..i wait(1) end Staus.Value = "Killer has Spawned" for i,v in pairs(game.Teams.Killer:GetPlayers()) do v.Character.HumanoidRootPart.CFrame = KillerSpawn.CFrame local Glow = Instance.new("PointLight") Glow.Color = Color3.new(1, 0, 0.0156863) Glow.Brightness = 40 Glow.Enabled = true Glow.Parent = v.Character.HumanoidRootPart end for i = ROUND_TIME, 0, -1 do Staus.Value = "Doors Will Open in "..i wait(1) end Staus.Value = "Gates are Open!" local OpenedGates = game:GetService("ServerStorage").OpenedGates local Gate1 = OpenedGates.Gate1:Clone() local Gate2 = OpenedGates.Gate2:Clone() for i,v in pairs(Gates:GetChildren()) do v:Destroy() end Gate1.Parent = workspace Gate2.Parent = workspace wait(2) for i = DoorCloseTime,0,-1 do Staus.Value = "Doors Close in "..i wait(1) end Staus.Value = "Doors CLOSED" wait(3)
end
Staus.Value = “Round Ended”
endspawn(Round)
LOCAL SCRIPT
local Player = game.Players.LocalPlayer
local Char = script.Parent
local Animations = script.Parent.Animations
local Prompt = workspace.Generator.PromptPart.ProximityPrompt
local Generator1 = workspace.Generator
local FixGenerator = game.ReplicatedStorage.FixGenerator
local humanoid = Char:WaitForChild(“Humanoid”)
local Animation = humanoid:LoadAnimation(Animations.GeneratorAnimation)
local ColorChange = BrickColor.new(“Lime green”)
Prompt.PromptButtonHoldBegan:Connect(function()
Animation:Play()
Animation.Looped = true
end)
Prompt.Triggered:Connect(function()
Animation:Stop()
FixGenerator:FireServer(Generator1,ColorChange)
end)