Searching for a model using string value

hello, i’m trying to make script which will see if there an object as value in string value. i even tried debugging, script works but the other part of the script doesn’t work

local UnlockedBy = script.Parent.UnlockedBy.Value


while wait(0.5) do
if script.Parent.Parent:FindFirstChild(UnlockedBy):FindFirstChild("IsBuy").Value == true then
	script.Parent.Head.Transparency = 0
	script.Parent.Head.Attachment.BillboardGui.Enabled = true
end
end

imagefordevforum1

Does your output show any errors? If not then i think you might have a spelling mistake in the string value as the code looks, ok.

No. output doesnt show any errors and there isn’t any spelling mistake in string value

Im going test the script myself and see if the code works.

it works but the other part of script dont work, like its not the full script

Well, to my eyes the script looks fine and i tested the script. I didnt find any errors or complications. So could you explain a bit more on the meaning “other part of the script”. That way i could try to help you.

after last end nothing will work

Why would you search for a model using a string value?

What are you trying to achieve with this script?

You need to break the loop to continue your code.

while wait(0.5) do
	if script.Parent.Parent:FindFirstChild(UnlockedBy):FindFirstChild("IsBuy").Value == true then
		--your code 
		
		break --add a break to the end
	end
end

it is helpful for tycoon system

while wait(0.5) do
if script.Parent.Parent:FindFirstChild(UnlockedBy):FindFirstChild(“IsBuy”).Value == true then
script.Parent.Head.Transparency = 0
script.Parent.Head.Attachment.BillboardGui.Enabled = true
end
end

In this code you’re checking for a Child in “UnlockedBy” that doesn’t exist, based on the screenshot.
image

You would do

while wait(0.5) do
if script.Parent.Parent[UnlockedBy]:FindFirstChild(“IsBuy”).Value == true then
script.Parent.Head.Transparency = 0
script.Parent.Head.Attachment.BillboardGui.Enabled = true
break
end
end

thanks a lot, i lost a lot of time because of this issue.

1 Like

No proplem, im always happy to help.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.