Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

2 comments

0

since it is stored in server storage you would use a serverscript

0

near a certain radius, not really..... its more near a part...

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.