Ok so I'm working on a small thing that uses magnitude. Basically in workspace there's a folder that contains parts which are all named the same thing however the parts are spread around the map. The local script gets the folder and checks whether the name of the part is "Hello," if the name is "Hello," then the local script makes a simple text label visible. Hope this kind of gives you an idea of what I'm trying to do.
while wait() do local checkPart = game.Workspace.Wow:GetChildren() --Folder in workspace if checkPart.Name == "Hello" then local dis = (game.Workspace.checkPart.Position - game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude if dis <= 10 then script.Parent.TextLabel.Visible = true wait() end if dis >= 9 then script.Parent.TextLabel.Visible = false wait() end wait() end wait() end
I edited your script a bit the script is using "For loops" to loop throw all the parts in the folder and checks if the name is correct (hello) its not perfect but it will take me time to fix the Flashes (i know what is the problem)
while true do for i,v in pairs(game.Workspace.Wow:GetChildren()) do if v.Name == "Hello" then local dis = (v.Position - game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position).magnitude if dis <= 10 then script.Parent.TextLabel.Visible = true wait() else script.Parent.TextLabel.Visible = false wait() end end end end
ok finally I got the fixed version
local c script.Parent.TextLabel.Visible = false while true do for i,v in pairs(game.Workspace.Wow:GetChildren()) do wait() if v.Name == "Hello" then local dis = (v.Position - game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position).magnitude if dis <= 10 then script.Parent.TextLabel.Visible = true wait() c = i else if i == c then script.Parent.TextLabel.Visible = false wait() local c = nil end end end end end