I have a regular script and a local script.
The local script is inside the gui. The regular script is the control.
My script shows what class they are(Sheriff, Bloxxer, Bystander). Whenever my script gets to that part, it doesn't show what they are.
Also, my local script doesn't show the intermission. Help?
ERROR: 14:19:08.441 - ReplicatedStorage.RemoteEvent: OnClientEvent can only be used on the client
INTERMISSION
function secondstotimer(seconds) local minutes = math.floor(seconds / 60) local remainingseconds = seconds % 60 if remainingseconds <= 0 then remainingseconds = "00" elseif remainingseconds <= 9 then remainingseconds = "0" .. remainingseconds end return tostring(minutes) .. ":" .. remainingseconds end
CLASSES
event.OnClientEvent:connect(function(...) local tuple = {...} if tuple[1] == "Result" then if tuple[2] == "BloxxerWin" then resultname.Text = "Mad Bloxxer wins!" resultname.TextColor3 = Color3.new(1, 74/255, 77/255) resultdesc.Text = "All players were bloxxed." else resultname.Text = "Players win!" resultname.TextColor3 = Color3.new(111/255, 149/255, 1) resultdesc.Text = "All players were bloxxed." end resultprompt.Visible = true resultprompt.Position = UDim2.new(0, -400, .5, -92) resultprompt:TweenPosition(UDim2.new(.5, -170, .5, -92), "Out", "Quad", 1) wait(7) resultprompt:TweenPosition(UDim2.new(1, 60, .5, -92), "Out", "Quad", 1) elseif tuple[1] == "Class" then if tuple[2] == "Bloxxer" then classname.Text = "You are the Mad Bloxxer" classname.TextColor3 = Color3.new(1, 74/255, 77/255) classdesc.Text = "Your goal is to blox everyone!" end elseif tuple[2] == "Sheriff" then classname.Text = "You are the Sheriff" classname.TextColor3 = Color3.new(111/255, 149/255, 1) classdesc.Text = "Your goal is to find the Mad Bloxxer and put them away for good!" else classname.Text = "You are a Bystander" classname.TextColor3 = Color3.new(117/255, 1, 156/255) classdesc.Text = "Your goal is to help the Sheriff find the Mad Bloxxer." end classprompt.Visible = true classprompt.Position = UDim2.new(0, -400, .5, -92) classprompt:TweenPosition(UDim2.new(.5, -170, .5, -192), "Out", "Quad", 1) wait(7) classprompt:TweenPosition(UDim2.new(1, 60, .5, -92), "Out", "Quad", 1) end)
FIRES CLASSES
if player == bloxxer then local sword = serverstorage:WaitForChild("Sword"):clone() sword.Parent = backpack event:FireAllClients("Class", "Bloxxer") elseif player == sheriff then local gun = serverstorage:WaitForChild("Gun"):clone() gun.Parent = backpack event:FireAllClients("Class", "Sheriff") else event:FireAllClients("Class", "Bystander") end end
RESULTS
local gameresult = "PlayersWin" if bloxxeractive then if #contestants >= 2 then event:FireAllClients("Result", "PlayersWin") else gameresult = "BloxxerWin" event:FireAllClients("Result", "BloxxerWin") end else event:FireAllClients("Result", "BloxxerWin") end
RemoteEvents are handled in either a server script or a local script, then fired in the opposite type of script from where it was handled. (if this is not what you're looking for, use a BindableEvent instead)
The way it works is you use OnServerEvent
to handle a RemoteEvent in a server script, and OnClientEvent
to handle it in a local script. If you try to use OnServerEvent
in a local script or OnClientEvent
in a server script, the same error that you got will appear.
Conclusion:
Use OnServerEvent
if you are doing this from a server script.