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

How do I give a player a Gui when they get near a certain radius?

Asked by 5 years ago

I have an invisible part that triggers when a player touches it. here is my method

function onTouch(Hit)
hum = Hit.Parent:FindFirstChild("humanoid")
if hum ~= nil then
--here is where the code gets executed
end
end

script.Parent.Touched:Connect(onTouch)

However, I cannot figure out the part where you transfer the parent of the Gui from serverstorage to PlayerGui. I even do not know if I should use localscript or regular script.

0
since it is stored in server storage you would use a serverscript Donut792 216 — 5y
0
near a certain radius, not really..... its more near a part... greatneil80 2647 — 5y

1 answer

Log in to vote
1
Answered by
Donut792 216 Moderation Voter
5 years ago

off the top of my head im pretty sure this should work

function onTouch(Hit)
hum = Hit.Parent:FindFirstChild("humanoid")
if hum ~= nil then
local clone = game.ServerStorage.NameOfGui:Clone() -- clone the gui
local player = game.Players:GetPlayerFromCharacter(Hit.Parent) -- grab player
clone.Parent = player.PlayerGui -- clone into playergui
end
end

script.Parent.Touched:Connect(onTouch)
Ad

Answer this question