I want to make OnServerEvent:Connect(function(player) when I click the imagebutton in the game.startergui.imagebutton location but it doesn’t work I have used several ways such as using fireserver, and running the server with mousebuttonclick1.onserverevent:function() still doesn’t work any help?
local CollectionService = game:GetService("CollectionService") local rep = game.ReplicatedStorage local interactionEvent = Instance.new("RemoteEvent", script.Parent) local Loop = true CollectionService:AddTag(script.Parent, "Interactable") interactionEvent.Name = "InteractionEvent" interactionEvent.OnServerEvent:Connect(function(player) if player:FindFirstChild("Npc") then return end local there = false
I think there might be something that prevents the event from firing an event, like collectionservice?
Just a thing im going to add to this is that the Remote event needs to be in a place both server and client can see like Replicated storage or under the button alongside the script (if its supposed to happen for each player exclusively)
you can do FireClient:() to fire OnClientEvent for a specific player anyways so it wouldnt make sense to have separate remote events, just one in replicated storage.