signal is nil so i can't disconnect it from RBLXScriptSignal, it returns this: " ServerScriptService.ProceduralGen:50: attempt to index global 'signal' (a nil value)". I don't get it...
local closeByCheck = function(ply,n) print("Called") local signal = ply:FindFirstChild("Right Leg").Touched:connect(function(otherPart) signal:disconnect() print("Touched") print(otherPart.Parent) if otherPart.Parent == game.Workspace.Grid then print("Part is grid") if (ply.HumanoidRootPart.Position - otherPart.Position).magnitude < startRange then print("Part is close") print("N is: "..n) closeByPart[n] = otherPart end end end) return true end
It's because signal
isn't local in the function scope
A suitable fix is to introduce signal
as a local before creating the function
local closeByCheck = function(ply,n) print("Called") local signal signal = ply:FindFirstChild("Right Leg").Touched:connect(function(otherPart) signal:disconnect() print("Touched") print(otherPart.Parent) if otherPart.Parent == game.Workspace.Grid then print("Part is grid") if (ply.HumanoidRootPart.Position - otherPart.Position).magnitude < startRange then print("Part is close") print("N is: "..n) closeByPart[n] = otherPart end end end) return true end