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

How do you access the player [player gui] in filtering enabled mode?

Asked by
Scaii_0 145
7 years ago

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?

2 answers

Log in to vote
0
Answered by
mraznboy1 194
7 years ago

You would have to use a remote function. The server side would handle the part where it detects the touch:

1local 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.
2 
3function onTouch(hit)
4    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
5         RemoteEvent:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
6    end
7end
8 
9script.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:

01local RemoteEvent = game.ReplicatedStorage.RemoteEvent --again, make sure this name matches up to the RemoteEvent you're firing in the server script.
02local player = game.Players.LocalPlayer
03 
04function ShowGui()
05    local gui = game.ReplicatedStorage.GUI_NAME:clone() --whatever you called it
06    if (not player.PlayerGui:FindFirstChild(gui.Name)) then
07        gui.Parent = player.PlayerGui
08    end
09end
10 
11RemoteEvent.OnClientEvent:connect(ShowGui)
1
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. Scaii_0 145 — 7y
0
No problem! It's very easy, just make sure to keep everything organized or you can easily lose yourself. mraznboy1 194 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You don't need to use remote events. You can do everything in the server script.

01-- In a server script within the part being touched
02local part = script.Parent
03 
04part.Touched:connect(function(otherPart)
05    if otherPart.Parent then
06        local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
07        if player and not player.PlayerGui:FindFirstChild("ScreenGui") then
08            game.ServerStorage.ScreenGui:Clone().Parent = player.PlayerGui
09        end
10    end
11end)
0
This is what I used a short while after mraznboy's reply and some experimenting. Scaii_0 145 — 7y

Answer this question