✓ Accepted answer
You would have to use a remote function. The server side would handle the part where it detects the touch:
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
function onTouch(hit)
if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
RemoteEvent:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
end
end
script.Parent.Touched:connect(onTouch)
This fires the event that lets the client do whatever is connected to the event. This connection would be defined in a LocalScript. You can place it in the StarterPlayerScripts or somewhere similar where localscripts can run:
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
local player = game.Players.LocalPlayer
function ShowGui()
local gui = game.ReplicatedStorage.GUI_NAME:clone()
if (not player.PlayerGui:FindFirstChild(gui.Name)) then
gui.Parent = player.PlayerGui
end
end
RemoteEvent.OnClientEvent:connect(ShowGui)
2 comments
Thank you for the introduction on FE. You taught me what no other roblox tutorial video could. I checked the wiki so do have a basic underrstanding but didn't know how to use it.
No problem! It's very easy, just make sure to keep everything organized or you can easily lose yourself.