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

How to use remote events?

Asked by 3 years ago

hi so i want to know how you can make remote events to happen server or client to make a gui visible i really need help heres my current attempt

local event = game.ReplicatedStorage.RemoteEvent

script.Parent.ClickDetector.MouseClick:Connect(function()
local player = game.Players.LocalPlayer
local gui = player.PlayerGUI
event:Fire(player,gui)
end)

1 answer

Log in to vote
2
Answered by
2_MMZ 1059 Moderation Voter
3 years ago
Edited 3 years ago

Here are the steps to your fixed script.

1) Make sure you have the Remote Event inside of ReplicatedStorage 2) Have your workspace script set to a regular script 3) Have a LocalScript inside of StarterGUI.

Next, we get to the scripting part.

Regular Script:

local event = game.ReplicatedStorage:WaitForChild("RemoteEventName")
local clickdetector = script.Parent

clickdetector.MouseClick:Connect(function(player)
event:fireClient(player)
end)

LocalScript:

local event = game.ReplicatedStorage:WaitForChild("RemoteEventName")

event.OnClientEvent:Connect(function()
--Put your desired line of code here
end)

Hope this helped you!

Ad

Answer this question