What I am trying to accomplish is, on touch, a GUI is replicated into the player GUI from server storage. I have done this without FE but I am looking to find out how to do it with FE.
On touch how would I get from the character to the player? And then their player GUI?
Would i have to use Remote Functions/Events or will something more simple like:
function onTouch(Humanoid) h=~nil then GetPlayerFromCharacter
will something like that do?
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 --name this whatever you'd like, and place it in the Replicated Storage, as both the Client and Server can access it. 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 --again, make sure this name matches up to the RemoteEvent you're firing in the server script. local player = game.Players.LocalPlayer function ShowGui() local gui = game.ReplicatedStorage.GUI_NAME:clone() --whatever you called it if (not player.PlayerGui:FindFirstChild(gui.Name)) then gui.Parent = player.PlayerGui end end RemoteEvent.OnClientEvent:connect(ShowGui)
You don't need to use remote events. You can do everything in the server script.
-- In a server script within the part being touched local part = script.Parent part.Touched:connect(function(otherPart) if otherPart.Parent then local player = game.Players:GetPlayerFromCharacter(otherPart.Parent) if player and not player.PlayerGui:FindFirstChild("ScreenGui") then game.ServerStorage.ScreenGui:Clone().Parent = player.PlayerGui end end end)