Soooooo, i was trying to do something, and one thing i noticed is that when an event is run, its constantly run until another event is run, i dont get it. my code:
RoleHandler (local script, located in starterplayerscripts):
local roundStart = game.ReplicatedStorage.remoteEvents.round.roundStart
local roundEnd = game.ReplicatedStorage.remoteEvents.round.roundEnd
local replicatedStorage = game.ReplicatedStorage
local roleFolder = game.ReplicatedStorage.remoteEvents.roles
local murdererChosen = game.ReplicatedStorage.remoteEvents.roles.murderer
local sheriffChosen = game.ReplicatedStorage.remoteEvents.roles.sheriff
local innocentChosen = game.ReplicatedStorage.remoteEvents.roles.innocent
local neutral = game.ReplicatedStorage.remoteEvents.roles.neutral
local randomRole = math.random(1, 3)
local theChosenRole = game.ReplicatedStorage.TheChosenRole
roundStart.OnClientEvent:Connect(function()
if randomRole == 3 then
--code here
murdererChosen:FireServer(randomRole)
theChosenRole.Value = "MURDERER"
elseif randomRole == 2 then
--code here
sheriffChosen:FireServer(randomRole)
theChosenRole.Value = "SHERIFF"
elseif randomRole == 1 then
--CODE HERE
innocentChosen:FireServer(randomRole)
theChosenRole.Value = "INNOCENT"
end
end)
roundEnd.OnClientEvent:Connect(function()
--code here
neutral:FireServer(randomRole)
theChosenRole.Value = "NEUTRAL"
end)
Display Role(server script, located in a GUI that is in starter GUI)
local chosenNumber = game.ReplicatedStorage.chosenNumber
local status = script.Parent.TextLabel
local tof = game.ReplicatedStorage:WaitForChild("displayChosenTOF")
local chosenRole = game.ReplicatedStorage:WaitForChild("TheChosenRole")
local inround = game.ReplicatedStorage.InRound
local murdererChosen = game.ReplicatedStorage.remoteEvents.roles.murderer
local sheriffChosen = game.ReplicatedStorage.remoteEvents.roles.sheriff
local innocentChosen = game.ReplicatedStorage.remoteEvents.roles.innocent
local neutral = game.ReplicatedStorage.remoteEvents.roles.neutral
local waittime = 5
local roundStart = game.ReplicatedStorage.remoteEvents.round.roundStart
local roundEnd = game.ReplicatedStorage.remoteEvents.round.roundEnd
innocentChosen.OnServerEvent:Connect(function(player, randomRole)
status.TextColor3 = Color3.new(3/255, 255/255, 19/255)
status.Text = "INNOCENT"
end)
murdererChosen.OnServerEvent:Connect(function(player, randomRole)
status.TextColor3 = Color3.new(255/255, 0/255, 4/255)
status.Text = "MURDERER"
end)
sheriffChosen.OnServerEvent:Connect(function(player, randomRole)
status.TextColor3 = Color3.new(16/255, 40/255, 255/255)
status.Text = "SHERIFF"
end)
neutral.OnServerEvent:Connect(function(player, randomRole)
status.TextColor3 = Color3.new(255/255, 255/255, 255/255)
status.Text = "IN LOBBY"
end)
Also, I didn't put a code to this, but I was trying to make it so that it appears for 5 seconds and it disappears, that works, but when it disappears it appears once again and continuously does that until a new event is run.
btw the --code here comments are just because I was doing something before that and marked that there.

1 comment
doesnt work.