This takes place inside a server script. The value is inside a server script also.
The print never printed, but I did one of those 2 player test and on the server side, the InARound value did update.
Is the value edited using a local script? If so, the new value isn’t replicated to the server.
To fix this, you need to update the value on the server using maybe a remote event.
I have a server script that controls the round system. When the round starts, the value is set to true, when the round ends, its set to false. Do you need to see the script?
If the code isn’t too long, it may help.
The script is rather long, but it’s all organized into functions.
--Things--
switch = game.Workspace.AllTheSwitches.DefaultSwitch
text = game.ReplicatedStorage.Status
playing = script.PlayersInRound
ReplicatedStorage = game:GetService("ReplicatedStorage")
playerDiedEvent = ReplicatedStorage:WaitForChild("PlayerDiedEvent")
--Variables--
--Switch Hiding Variables--
Map = nil
--HidingPlace = nil
NeededClicks = nil
Clicks = nil
--Round Variables--
Settings = game.ServerStorage.RoundSettings
RoundTime = Settings.RoundLength.Value
IntermissionTime = Settings.Intermission.Value
MinPlayers = Settings.MinPlayers.Value
--Player Related Variables--
Players = game.Players:GetChildren()
plrDiedLOL = game.ServerScriptService.PlayerDeathDetection.NameOfPlayerWhoDIedLOL
plrDied = game.ReplicatedStorage.PlayerDied
--Functions--
--Player Functions--
game.Players.PlayerAdded:Connect(function(player)
local val = Instance.new("BoolValue")
val.Name = "inRound"
val.Parent = player
end)
script.PlayerWhoEscaped:GetPropertyChangedSignal("Value"):Connect(function()
local plater = game.Players:FindFirstChild(script.PlayerWhoEscaped.Value)
if plater.inRound then
if plater.inRound.Value == true then
playing.Value = playing.Value - 1
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
playing.Value = playing.Value - 1
end)
local function onPlayerDied(playerName)
print("Player " .. playerName .. " has died.")
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
local plrName = player.Name
local plrInThisCase = game.Players:FindFirstChild(plrName)
if plrInThisCase:FindFirstChild("inRound") then
if plrInThisCase.inRound.Value == true then
playing.Value = playing.Value - 1
print(plrName.." was in the round so I gotta do something now :(")
else
print("They wern't in the round so I don't really care Womp Womp")
end
end
end)
end)
end)
--Round Functions--
script.PlayerWhoEscaped:GetPropertyChangedSignal("Value"):Connect(function()
playing.Value = playing.Value -1
end)
function CheckPlayers()
print("Checking Players")
wait(2)
if script.InARound.Value == false then
if #game.Players:GetChildren() >= MinPlayers then
if script.roundStarting.Value == false then
print("Starting Round")
wait(1)
StartRound()
wait(1)
end
else
text.Value = "Not enough players..."
print("Waiting...")
end
end
end
function StartRound()
script.roundStarting.Value = true
for i = IntermissionTime, 0, -1 do
wait(1)
text.Value = "Round Will Begin in "..i.." Seconds."
if #game.Players:GetChildren() >= MinPlayers then
print("Starting Round")
if i == 0 then
playing.Value = script.PlayersInServer.Value
for i, player in pairs(game.Players:GetChildren()) do
wait(1)
player.inRound.Value = true
end
script.InARound.Value = true
FindTheStick()
end
else
text.Value = "Not enough players..."
print("Waiting...")
script.roundStarting.Value = false
break
end
end
end
--script.InARound:GetPropertyChangedSignal("Value"):Connect(CheckPlayers)
script.PlayersInServer:GetPropertyChangedSignal("Value"):Connect(CheckPlayers)
function EndRound()
print("EndRound Funcftion fired")
if playing.Value < MinPlayers and script.InARound.Value == true then
print("Less than enough players to conteniue, ending round")
local sclone = game:FindFirstChild("sclone", true)
wait(1)
playing.Value = 0
if game:FindFirstChild("sclone", true) then
print("sclone")
local sclone = game:FindFirstChild("sclone", true)
if sclone.Parent:FindFirstChild("Humanoid") then
print("sclone ahs parrent")
local player = game.Players:FindFirstChild(sclone.Parent.Name)
script.PlayerWhoFoundTheStick.Value = sclone.Parent.Name
task.wait(0.1)
local char = game.Workspace:FindFirstChild(player.Name)
local target = CFrame.new(16.782, 34.706, -9.106)
char:PivotTo(target)
sclone.Parent = player.Backpack
task.wait(0.1)
sclone:Destroy()
game.Lighting.SwitchAtmospere:Destroy()
game.Lighting.SwitchSky:Destroy()
wait(5)
game.ReplicatedStorage.RoundEnded:FireAllClients()
wait(2)
end
end
for i, player in pairs(game.Players:GetChildren()) do
if player.inRound.Value == true then
local char = game.Workspace:FindFirstChild(player.Name)
char.Humanoid.WalkSpeed = 16
local hmnd = char.HumanoidRootPart
if char.Humanoid.Health <= 0 then
end
if hmnd.Parent.Humanoid.Health > 0 then
game.ServerScriptService["MainRoundScriptV.6ChatGPT"].SwitchFound.Value = false
end
end
end
script.InARound.Value = false
script.roundStarting.Value = false
if game.Lighting.SwitchAtmospere then
game.Lighting.SwitchAtmospere:Destroy()
end
if game.Lighting.SwitchSky then
game.Lighting.SwitchSky:Destroy()
end
script.SwitchFound.Value = false
end
end
script.InARound:GetPropertyChangedSignal("Value"):Connect(CheckPlayers)
playing:GetPropertyChangedSignal("Value"):Connect(EndRound)
--FindTheStick--
function FindTheStick()
ResetGame()
local sclone = switch:Clone()
sclone.Handle.Position = Vector3.new(154.88, 22.679, 327.46)
sclone.Handle.Anchored = false
sclone.Parent = game.Workspace
sclone.Name = "sclone"
task.wait(1)
if Map == 1 then
for i, player in pairs(game.Players:GetChildren()) do
local char = player.Character
local hmnd = char.HumanoidRootPart
local target = CFrame.new(-46.635, 14.372, 370.734)
char:PivotTo(target)
end
local HMitem = 16
local HMitemS = game.Workspace.HouseMap.HMItems:GetChildren()
print(HMitem)
game.Workspace.HouseMap.HMItems:FindFirstChild("HM_"..HMitem).isthething.Value = true
print(NeededClicks)
task.wait(1)
repeat
if playing.Value < MinPlayers then
print("Everyone died LOL")
break
end
task.wait()
if game.Workspace.HouseMap.HMItems:FindFirstChild("HM_"..HMitem).isthething.Value == true and game.Workspace.HouseMap.HMItems:FindFirstChild("HM_"..HMitem).clicked.Value == true then
Clicks = Clicks + 1
print(Clicks.. ", "..NeededClicks)
wait(0.2)
if Clicks == NeededClicks then
if HMitem > 5 then
local bushPos = game.Workspace.HouseMap.HMItems:FindFirstChild("HM_"..HMitem).CFrame + Vector3.new(0, 6, 0)
sclone.Handle.CFrame = bushPos
end
if HMitem < 6 then
local rockPos = game.Workspace.HouseMap.HMItems:FindFirstChild("HM_"..HMitem).paart.CFrame + Vector3.new(0, 3, 0)
sclone.Handle.CFrame = rockPos
end
end
end
until Clicks == NeededClicks
end
end
function ResetGame()
Map = 1
NeededClicks = math.random(1, 5)
Clicks = 0
end
--function Round()
-- CheckPlayers()
-- FindTheStick()
--end
--while true do
-- task.wait()
-- if playing.Value == 0 then
-- Round()
-- end
--end
The place where the InARound value is changed is in the StartRound Function.
Here’s just the StartRound Function
function StartRound()
script.roundStarting.Value = true
for i = IntermissionTime, 0, -1 do
wait(1)
text.Value = "Round Will Begin in "..i.." Seconds."
if #game.Players:GetChildren() >= MinPlayers then
print("Starting Round")
if i == 0 then
playing.Value = script.PlayersInServer.Value
for i, player in pairs(game.Players:GetChildren()) do
wait(1)
player.inRound.Value = true
end
script.InARound.Value = true
FindTheStick()
end
else
text.Value = "Not enough players..."
print("Waiting...")
script.roundStarting.Value = false
break
end
end
end
If you need anymore info just tell me.
Can you try editing your first piece of code like so (and tell me if print is printed as expected):
roundVal = game.ServerScriptService["MainRoundScriptV.6ChatGPT"].InARound
roundVal:GetPropertyChangedSignal("Value"):Connect(function()
print("roundtimerstarted")
for i = game.ServerStorage.RoundSettings.RoundLength.Value, 0, -1 do
game.ReplicatedStorage.Status.Value = "Round will end in "..i.." seconds."
wait(1)
end
end)
-- Manually toggle the value to test
roundVal.Value = not roundVal.Value
It will help us to know whether the issue comes from the first or the second piece of code.
It did not print. I started a round and toggled the value on and off. I may have put the script in the wrong place. It replaces the original script, right?
Can you send a picture of your workspace tree with the two scripts displayed on it?
Nether script is in the workspace. Ill send a pic of where they are though.
Sorry, I meant the explorer window.
If I remeber well, scripts can’t be executed when in the ReplicatedStorage
, which mean that your first piece of code will never run.
To fix this, you need to rework your game structure, server code should be placed in ServerScriptService
.
Another solution would be to set the run context of the script from “Legacy” to “Server”.
Do they both work the same way, or is one better than the other?
I can’t verbally describe how thankful I am, my Roblox game is now finished! I really appreciate your help, and I hope you have a good day.
I dont think there is a big difference between both.
My opinion is that run context give us more flexibility, but the legacy system forced developer to keep some sort of separation between client and server sides which is a good thing most of the times.
Reading this article should give you enough infos.
However, if you want to learn even more, feel free to create a post in the “dev discussions” category.
You’ll get more reviews by doing so.
Anyway, it was a pleasure to help you as much as I can.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.