Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Remote Events only working in client??

Hello.. I have a problem. Im trying to make my Bus Spawner GUI Spawn a vehicle using remote event. And It works in client but it does not work on the server (with filtering enabled) Script 01

script.Parent.Veh4.MouseButton1Click:connect(function()
	script.Parent.SpawnRemote.Value = true
end)

Thats the first script and that was sending a signal to the other script using BOOL VALUES. The script is a normal script not local. SCRIPT 02

while true do
	wait(0.01)
	if script.Parent.SpawnRemote.Value == true then
		game.ReplicatedStorage.Spawn:FireServer()
		script.Parent.Enviro200.Value = true
		script.Parent.SpawnRemote.Value = false
	end
end

that script was a LOCAL SCRIPT Not a normal script. That script fire's the Remote event. Script 03

game.ReplicatedStorage.Spawn.OnServerEvent:connect(function()
	while true do
	wait(1)
	if script.Parent.Parent.Enviro200.Value == true then
	   local Mod = game.ServerStorage.Enviro200     --Change test to whatever you have named the item you want to spawn
	   local clone = Mod:clone()
	   script.Parent.Parent.Enviro200.Value = false
	   clone.Parent = workspace
	   script.Parent.Parent.Visible = false
	end
	end
end)

That script is when the remote event is fired and it spawns in the bus.

Im trying to make my vehicle/bus spawner gui work with filtering enabled but it's just not working on a Filtering Enabled Server. I have tried lots of ways to fix it but its just not working. Please help.

2 comments

0

If you want to do client to server, in the local script :FireServer() should be there. OnServerEvent function is on the server side.

0

Same goes with server to client, :FireClient() on server side and OnClientEvent function on client side. If you're confused, maybe someone can explain it better than me but this is my understanding on it. Try and practice Remote Events a lot to get use to it.

1 answer

✓ Accepted answer

Local Script:

local ExampleEvent = game:GetService("ReplicatedStorage"):WaitForChild("Example")
local GUIButton = script.Parent

GUIButton.MouseButton1Down:Connect(function()
ExampeEvent:FireServer()
end)

Server Side:

local ExampleEvent = game:GetService("ReplicatedStorage"):WaitForChild("Example")
local Car = game:GetService("ServerStorage").Bus:Clone()

ExampleEvent.OnServerEvent:Connect(function(player)
local vehicle = Car
vehicle.Parent = game.Workspace.SpawnLocation
end)

This is an example, but :FireServer() is on the client side when firing the Remote Event. OnServerEvent function goes to the server side.

This discussion is preserved as it was. New answers, comments, and votes are closed.