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

How to fix: attempt to index global 'n' (a number value) ?

Asked by 6 years ago
Edited 6 years ago

I'm trying to put a gui's adornee on the closest part. The part is spawned when people click a button. I tried to use this script:

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:WaitForChild("NumVal").Value = sAway
13        end
14    end
15    n = 0
View all 30 lines...

but it says "attempt to index global 'n' (a number value)" Also, the person who spawned the part can only see the gui on that part.

Any help?

0
line 22: n.Value? GoldAngelInDisguise 297 — 6y
0
yas, whats n.Value? n is a variable?? starmaq 1290 — 6y

Answer this question