Remote Events not working

So I am currently trying to make a game and I am in need of remote events. The problem is that it is not getting the fire on the server. I am trying to fire a remote event on a local script when the player clicks a gui button. On the server I want it to run a function when the remote event is fired. I have looked at a article already but I am not finding it useful I might just be doing it wrong.

Thankyou for your help.

1 Like

if you need some of the code I can post it

1 Like

everyone needs the code to solve issues

When you want to fire a remote event you have to do it from a client script by saying that path of the remote event and doing :FireServer() also inside the brackets you can send optional data.

Then in a server script you also say the path of the remote event and then say .OnServerEvent:Connect(function(player)
and put code here you want to do.

If you want any more help please provide some more information to help you

1 Like

ok

local script

local afkEvent = game.ReplicatedStorage:WaitForChild(“AfkEvent”)

local tempAfkButton = script.Parent.TextButton

tempAfkButton.MouseButton1Up:Connect(function()

afkEvent:FireServer()

end)

Server script

local afkEvent = game.ReplicatedStorage:WaitForChild(“AfkEvent”)

local idle = {}

local playing = {}

afkEvent.OnServerEvent:Connect(function(player)

print(player.Name…" has fired this event")

end)

1 Like

where have you placed the local script?

1 Like

prefix the code with ```
example:

CODE

CODE --with prefix

1 Like

I have the local script in starter gui in a screen gui. the server script is in serverscriptservice

1 Like

Are you sure it’s MouseButton1Up? I think you have to put MouseButton1Click

local script


local tempAfkButton = script.Parent.TextButton

tempAfkButton.MouseButton1Up:Connect(function()

afkEvent:FireServer()

end) 

Server script

local afkEvent = game.ReplicatedStorage:WaitForChild(“AfkEvent”)

local idle = {}

local playing = {}

afkEvent.OnServerEvent:Connect(function(player)

print(player.Name…" has fired this event")

end)

mousebutton1Up does work i have used it on many other things. I will try it though just to be sure

I think then it should be fine. This is getting printed in the server not the client. So when you go in the server in the dev console it doesn’t get printed?

So i am testing this in play mode on roblox studio is that a problem, i am also looking in the output

Try put 2 dots here
image

2 Likes

it does have two dots i think its just displaying wrong up there

also the problem is its not reaching the afkEvent.OnServerEvent:Connect(function(player)

change

local afkEvent = game.ReplicatedStorage:WaitForChild(“AfkEvent”)

to

local afkEvent = game.ReplicatedStorage:WaitForChild("AfkEvent")
1 Like

I’m confused I don’t see any difference other then the color

Where is your local variable for this here?