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

How do you make a gui's adornee go on a part that is closest to you and at least 10 studs away?

Asked by 6 years ago

I'm trying to make a gui's adornee on a part that is spawned by someone when they click a button. Also, the person who spawned the part is the only one who can see the gui on that part. The gui will only pop up if the part is the closest to the player that spawned it and is ten studs away.

I tried doing this:

01local plrName = script.Parent.Name
02local rK = game.Players:GetPlayerFromCharacter(script.Parent).PlayerGui:WaitForChild("RKeyGen")
03 
04while true do
05    for i, v in pairs(game.Workspace.Bricks:GetChildren())do
06        if v.Name == plrName then
07            local pPos = v.Position
08            local lPos = script.Parent:FindFirstChild("HumanoidRootPart").Position
09            local pAvg = (pPos.X + pPos.Y + pPos.Z)/3
10            local lAvg = (lPos.X + lPos.Y + lPos.Z)/3
11            local sAway = math.abs(pAvg - lAvg)
12            v.NumVal.Value = sAway
13        end
14    end
15    n = 0
View all 30 lines...

But, the gui just pops up even when theres other parts closest to me and it stays on the same part even when i am like, 30 studs away from it.

Any help?

0
If you're doing this in a local script (Which you should), you should use game.Players.LocalPlayer for line 02. xPolarium 1388 — 6y

Answer this question