So, im making an murder mystery game, and the thing that appears on start of the round is the "show my role" gui or "show me if im murderer or innocent or sheriff" gui, and i first tried to do it in the script in the serverscriptservice because thats where my main stuff about rounds and intermission timing and stuff is located, but that didnt work, the next thing i tried was to do it with the boolvalue (i had 2 of them in my script, one for saying when the round starts and ends, and one that says to display the "show my role" gui), and that didnt work either, so a few minutes before, i tried to do it with the inround value(which in fact did work) but then the text stopped to change, and after that it just breaks, and shows the gui when the player is in lobby, and hides it when the player is in round.
My code is (Main Script):
local roundLength = 5 local intermissionLength = 5 local status = game.ReplicatedStorage.IntermissionStatus local inround = game.ReplicatedStorage.InRound local chosenRandomNumberValue = game.ReplicatedStorage.chosenNumber local displaychosenrole = game.StarterGui.areyoumurdorsherifforinno.Chosen.TextLabel local tof = game.ReplicatedStorage.displayChosenTOF local player = game.Players.LocalPlayer local chosenRoleValue = game.ReplicatedStorage.TheChosenRole local murdererteam = game.Teams.Murderer local sheriffteam = game.Teams.Sheriff local innocentteam = game.Teams.Innocent local mineshaft = game.Workspace.MineshaftSpawn local milbase = game.Workspace.MilbaseSpawn local lobby = game.Workspace.LobbySpawn local colorRed = Color3.new(255/255, 0/255, 4/255) local colorBlue = Color3.new(16/255, 40/255, 255/255) local colorGreen = Color3.new(3/255, 255/255, 19/255) inround.Changed:Connect(function() if inround.Value == true then for _, player in pairs(game.Players:GetChildren()) do local char = player.Character local randomMapNumber = math.random(1,2) if randomMapNumber == 1 then char.HumanoidRootPart.CFrame = mineshaft.CFrame elseif randomMapNumber == 2 then char.HumanoidRootPart.CFrame = milbase.CFrame end local randomNumber = math.random(1,3) if randomNumber == 1 then player.TeamColor = BrickColor.new("Really red") chosenRoleValue.Value = "MURDERER" elseif randomNumber == 2 then player.TeamColor = BrickColor.new("Electric blue") chosenRoleValue.Value = "SHERIFF" elseif randomNumber == 3 then player.TeamColor = BrickColor.new("Lime green") chosenRoleValue.Value = "INNOCENT" end end else for _,player in pairs(game.Players:GetChildren()) do local char = player.Character char.HumanoidRootPart.CFrame = lobby.CFrame player.TeamColor = BrickColor.new("White") chosenRoleValue.Value = "NEUTRAL" end end end) local function roundTimer() while wait() do for i = intermissionLength, 1, -1 do inround.Value = false wait(1) status.Value = "Intermission: ".. i .." seconds left!" wait(1) end for i = roundLength, 1, -1 do inround.Value = true wait(1) status.Value = "Game: ".. i .." seconds left!" end end end spawn(roundTimer)
My code for the gui script:
local chosenNumber = game.ReplicatedStorage.chosenNumber local status = script.Parent.TextLabel local tof = game.ReplicatedStorage.displayChosenTOF local chosenRole = game.ReplicatedStorage.TheChosenRole local inround = game.ReplicatedStorage.InRound chosenRole.Changed:Connect(function() if chosenRole.Value == "MURDERER" then status.TextColor3 = Color3.new(255/255, 0/255, 4/255) status.Text = "MURDERER" if inround.Value == true then script.Parent.Parent.Chosen.Visible = true wait(5) script.Parent.Parent.Chosen.Visible = false end elseif chosenRole.Value == "SHERIFF" then status.TextColor3 = Color3.new(16/255, 40/255, 255/255) status.Text = "SHERIFF" if inround.Value == true then script.Parent.Parent.Chosen.Visible = true wait(5) script.Parent.Parent.Chosen.Visible = false end elseif chosenRole.Value == "INNOCENT" then status.TextColor3 = Color3.new(3/255, 255/255, 19/255) status.Text = "INNOCENT" if inround.Value == true then script.Parent.Parent.Chosen.Visible = true wait(5) script.Parent.Parent.Chosen.Visible = false end elseif chosenRole.Value == "NEUTRAL" then status.TextColor3 = Color3.new(255/255, 255/255, 255/255) status.Text = "NEUTRAL" if inround.Value == true then script.Parent.Parent.Chosen.Visible = true wait(5) script.Parent.Parent.Chosen.Visible = false end end end)
also the main script is an "script" and the second is an "local script"
I noticed a couple problems with your script here:
You are using a server sided value called chosenRole, but the problem is in the local script, you are looking for every time it is changed. What I mean is, everyone will be the murderer when they start the game. Instead, use a remote event, and fire it with the team that they will be on instead of changing a value.
You are being heavily dependent on ReplicatedStorage, but the thing is, exploiters can easily change these values to their liking. Use remote events and functions instead of changing a value directly.
Instead of complicating stuff and using Color3.new
, use Color3.fromRGB
, this will allow you to change color much more easily.
There is a for loop that is not properly indented on line 77.
I’m sorry if I sound like a know it all, but the thing is, your script needs a major rewrite. It needs to be a bit more cleaner and safer from exploiters.
I’ll post another answer with some scripts you could use if you’d like.