My Remote event isnt working

Hi my remote event isnt working, not sure why… i’m new to remote events so am a bit confused
snippppppplol1

1 Like

Have you sent a server event using “game.ReplicatedStorage.RemoteEvent:FireServer()”?

2 Likes

You’ve only defined the event.

You will need to call it afterward.

In this situation, I wouldn’t use a RemoteEvent in my opinion, and would just leave the script.Parent.Visible by itself.

But, if you were to call it, you would call it as game.ReplicatedStorage.RemoteEvent:FireServer().

EDIT:
Also, this is unrelated but you don’t need to use == true at the end in your if statement. It will still evaluate correctly without it.

2 Likes

I have the 'game.ReplicatedStorage.RemoteEvent:FireServer() in a local script in StarterGui with nothing else… is this wrong or do I need to somewhere else?

1 Like

You should keep events mostly outside of regular functions. In you’re case you should call your startEvent() function from inside your OnServerEvent event.

It’s also best practice to use :FindFirstChild rather than straight indexing from the hierarchy. You should also try and keep more variables instead of indexing each item one at a time.

Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:FindFirstChild("RemoteEvent") -- Remote name

local function StartEvent()
    --- Event stuff
end

RemoteEvent.OnServerEvent:Connect(function(player)
     -- When fired execute
    if standingOnPart1 == true and standingOnPart2 == true then -- Condition
          script.Parent.Visible = true
          -- Room to call StartEvent

     end
end)

Local Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:FindFirstChild("RemoteEvent") -- Remote name

RemoteEvent:FireServer()
3 Likes

What are you trying to call an event for?

2 Likes

Thank you very much for the help, I added your script but the GUI still isnt showing up…

--VARIABLES

local part1 = game.Workspace.Player1

local part2 = game.Workspace.Player2

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:FindFirstChild("RemoteEvent")

------------------------------------------------------------------------------------------

--PLAYER 1 START

part1.Touched:Connect(function()
	part1.BrickColor = BrickColor.new("Teal")
end)

part1.TouchEnded:Connect(function()
	part1.BrickColor = BrickColor.new("Smoky grey")
end)

------------------------------------------------------------------------------------------

--PLAYER 2 START

part2.Touched:Connect(function()
	part2.BrickColor = BrickColor.new("Teal")
end)

part2.TouchEnded:Connect(function()
	part2.BrickColor = BrickColor.new("Smoky grey")
end)

------------------------------------------------------------------------------------------

local standingOnPart1 = false
local standingOnPart2 = false

local function startEvent()

end

RemoteEvent.OnServerEvent:Connect(function(player)
	-- When fired execute
	if standingOnPart1 == true and standingOnPart2 == true then -- Condition
		script.Parent.Visible = true
		-- Room to call StartEvent

	end
end)

part1.Touched:Connect(function(touched)

	local playerTouchedOrNot = game:GetService("Players"):GetPlayerFromCharacter(touched.Parent)

	if playerTouchedOrNot then

		if standingOnPart1 ~= true and part2.Name ~= playerTouchedOrNot.Name then

			standingOnPart1 = true

			part1.Name = playerTouchedOrNot.Name

			startEvent()

		end

	end

end)

part1.TouchEnded:Connect(function(touched)

	local playerTouchedOrNot = game:GetService("Players"):GetPlayerFromCharacter(touched.Parent)

	if playerTouchedOrNot then

		if standingOnPart1 ~= false and part1.Name == playerTouchedOrNot.Name then

			standingOnPart1 = false

			part1.Name = "part1"

		end

	end

end)

part2.Touched:Connect(function(touched)

	local playerTouchedOrNot = game:GetService("Players"):GetPlayerFromCharacter(touched.Parent)

	if playerTouchedOrNot then

		if standingOnPart2 ~= true and part1.Name ~= playerTouchedOrNot.Name then

			standingOnPart2 = true

			part2.Name = playerTouchedOrNot.Name

			startEvent()

		end

	end

end)

part2.TouchEnded:Connect(function(touched)

	local playerTouchedOrNot = game:GetService("Players"):GetPlayerFromCharacter(touched.Parent)

	if playerTouchedOrNot then

		if standingOnPart2 ~= false and part2.Name == playerTouchedOrNot.Name then

			standingOnPart2 = false

			part2.Name = "part2"

		end

	end

end)
1 Like

I got told by someone that I need to call an event in order to make the gui show up

1 Like

Your event is called immediately, with no response set yet.

Essentially, you’re calling a blank function.

2 Likes

Oh ok, thanks, how would i set a response?

1 Like
game.ReplicatedStorage.RemoteEvent:FireServer() -- call the event
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr) -- receive event
--what you want to happen
end) 
2 Likes

I believe I have got that in my script yet it’s still not working

1 Like

You could send the “OK” with another RemoteEvent, but that would be more code than necessary.

Personally I wouldn’t use a RemoteEvent in this situation altogether.

2 Likes

Is the Fire and Receive in the same script?

2 Likes

No the recieve is in a server script and the fire is in a local script

1 Like

I’m a little bit confused. If your receiving script is in ServerScriptService then why does it say “script.Parent.Visible = true”?

2 Likes

I tried to do it without a remote event but it didnt work for some reason

1 Like

I thought that was weird, i watched a video where they did it like that but ill change it and see if it works

1 Like

The event is defined in a normal script. Calling FireServer will throw an error if used from the same script. Normal scripts can only call FireClient or FireAllClients.

2 Likes

In your receiving script it says, “script.Parent.Visible = true” but you can’t make ServerScriptService invisible/visible

2 Likes