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

Why is this event not being picked up by a script?

Ok so I have a local script in a gui that when clicked it fires an event along with the data char which is the character of the player and is meant to be picked up by a script in serverscriptservice. HOWEVER while the local script fires the event and I know that it does because it prints out a confirmation the server doesnt pick up the event and doesnt do its part.

This is the local script:

local player = game.Players.LocalPlayer
local char = player.Character
function OnClicked() 
	print "Clicked"
	game.ReplicatedStorage.JoinedMap:FireServer(char)
	print "EventSent"
end 

script.Parent.MouseButton1Down:connect(OnClicked)

And this is the server script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("JoinedMap")

local function JoinedMap(char)
	
	print "Event Recieved"
	
	char.Parent = game.Workspace.PlayersMap
	
	print "Set Parent"


	remoteEvent.OnServerEvent:Connect(JoinedMap)

end

Im so confused why isnt it getting picked up? It prints out "Clicked" and it prints out "EventSent "but the server does NOT print out "Event Received" nor does it print out "Set Parent"

3 comments

0

Ive tried to move my entire game over to a new classic baseplate just to make sure no malicious script is running and still it doesnt work

0

This SHOULD work there is absolutely no reason this isn't working I just dont understand, my code should be working fine

0

lol

1 answer

✓ Accepted answer

Try moving remoteEvent.OnServerEvent:Connect(JoinedMap) underneath end.

So:

local function JoinedMap(char)

    print "Event Recieved"

    char.Parent = game.Workspace.PlayersMap

    print "Set Parent"


end
    remoteEvent.OnServerEvent:Connect(JoinedMap)

2 comments

0

tysm I didnt know that was the issue!

0

No problem! The reason why it wasn't working was because the remote event that was supposed to call the function was in the actual function itself.

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