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

Magnitude not working with getchildren?

Ok so I have parts spread across a baseplate named "Hello" and so each part that is named "Hello" is inside a model and the model is inside a folder in workspace called "Wow." So whenever a player walks up to one of these parts, a simple text gui would become visible. Now this question was answered by someone named asdfghjk9019 however I forgot to mention that the parts where in different models. I tried making the script seeing whether the part was inside a model named "MAIN" which the model name of "Hello," however that was unsuccessful. I hope you guys kind of understand what I mean, sorry if it doesn't make sense. .~.

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" and v.Parent.Name == "MAIN" 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

1 answer

✓ Accepted answer

this should work

local player = game.Players.LocalPlayer
local partName

script.Parent.TextLabel.Visible = false

function makeGuiVisile(part)
	local dis = (part.Position - game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position).magnitude
	if dis <= 10 then
		script.Parent.TextLabel.Visible = true
		partName = part
	else
		if partName == part then
			script.Parent.TextLabel.Visible = false
		end
	end--]]
end

function checkThePartName(parent)
	
	for i,v in pairs(parent:GetChildren())do
		if v.Name == "Hello" then 
			makeGuiVisile(v)
		else
			checkThePartName(v)
		end
	end
end

while true do
	wait()
	checkThePartName(game.Workspace.Wow)--this is the start of the script make sure that the folder name is Wow
end





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