Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Remote Event problem or gui?

Asked by 4 years ago

I made a when this part is clicked then it fires the remoteevent its a localscript. Now in the frame i did onserverevent also a localscript. The problem is this, im not sure if this is a remote event problem or a gui problem since the gui doesnt show up.

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

You cannot call OnServerEvent from a Client perspective. You cannot use a LocalScript on a ClickDetector either, so the fact is that you have everything essentially flipped. Use a ServerScript within a ClickDetector to Fire the RemoteEvent upon MouseClick. Use FireClient instead, and pass the Player returned by MouseClick as the target Client. Use the LocalScript within the Frame to pick up the OnClientEvent signal.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:FindFirstChild("RemoteEvent")
--// RemoteEvents should be stored as a child of RepStorage.

local ClickDetector = script.Parent

ClickDetector.MouseClick:Connect(function(PlayerClicked)
    RemoteEvent:FireClient(PlayerClicked)
end)

Assuming you used a ClickDetector to create a Part Clicked function as you cannot do this otherwise, give it a read-up to ensure you understand it better. Please also take another gander at RemoteEvents as you seem to have misunderstood the Client-Server communication process.

Remember, if this answer helps, don’t forget to accept it!

1
you are smartest man on earth DeadStroke509 3 — 4y
0
Thanks ;)! Ziffixture 6913 — 4y
Ad

Answer this question