But when I tested the script, :FireServer() seemed to work but the same doesn’t go for .OnServerEvent.
I’ve tried searching this problem on the forum but I didn’t find anything
As needed, here are the scripts. Keep in mind that both are regular scripts!
Script that uses FireServer()
You can use – not only as a comment but also executing code only for the client. (Probally an explanation on why there are comments in some scripts lol)
Example:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StartupEvent = ReplicatedStorage:WaitForChild("StartupEvent")
local Mode = 1
local Closed = script.Parent
local Open = script.Parent.Parent.Open
local Sound = script.Parent.Sound
local ClickDetector = script.Parent.ClickDetector
function onClicked(Mouse)
ClickDetector.MaxActivationDistance = 0
Sound:Play()
end
function startup()
Closed.Transparency = 1
Closed.CanCollide = false
Open.Transparency = 0
Open.CanCollide = true
--StartupEvent:FireServer(Mode)
print("Succesfully Fired Server!")
end
ClickDetector.MouseClick:Connect(onClicked)
ClickDetector.MouseClick:Connect(startup)
Script that gets OnServerEvent()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StartupEvent = ReplicatedStorage:WaitForChild("StartupEvent")
local Status = workspace.CoreStatus.CoreStatus
local Closed = workspace.Switch.Click.Closed
local Open = workspace.Switch.Click.Open
local Sound = workspace.Switch.Click.Closed.Sound
local ClickDetector = workspace.Switch.Click.Closed.ClickDetector
StartupEvent.OnServerEvent:Connect(function(Player, Mode)
if Mode == 1 then
print("Succesfully Got OnServerEvent!")
end
end)
Sorry if it’s hard to understand. For new year’s eve I was awake until 4:01 AM.
i tried using a localscript but its not even gonna print Succesfully Got OnServerEvent!
LocalScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StartupEvent = ReplicatedStorage:WaitForChild("StartupEvent")
local Mode = 1
local Closed = script.Parent
local Open = script.Parent.Parent.Open
local Sound = script.Parent.Sound
local ClickDetector = script.Parent.ClickDetector
function onClicked(Mouse)
StartupEvent:FireServer(Mode)
print("Succesfully Fired Server!")
end
ClickDetector.MouseClick:Connect(onClicked)
Yea but I found out that I can use a comment for it to do it only on the client.
If i’m trying it without the comment it will error saying that FireServer can only be used on the client.
What I’m trying to achieve is having the system bootup work. Not have a random GUI on the client pop up saying that it’s booting the systems. So that’s why I’m using :FireServer()
EDIT: Keep in mind that I tried using a LocalScript and it didn’t even print Succesfully Fired Server!
On the LocalScript there is only onClicked. I tried putting a print() before :FireServer() but still didn’t print anything. Only the Script seems to successfully use :FireServer()
Yo try use FireClient to solve your problem RemoteEvent | Roblox Creator Documentation
ps: You should call FireClient(plr) from server script
and get it on local script with use
local remote = game:GetService("ReplicatedStorage"):FindFirstChild("YourRemoteHere")
remote.OnClientEvent:Connect(function()
print("check")
end)
I have a similar issue with my subtitles. If someone joins right after :FireAllClients() was called, that player won’t get the subtitles. So therefore, the new player(s) won’t see a single startup.