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

"Obtained is not a valid member of image label" but it is...?

I honestly can not figure out what is wrong with this script, help.

It works in Solo It's in a GUI in starterGUI No, filtering is not enabled

function sheildon()
		script.Parent.Visible = true

end

function sheildoff()
	script.Parent.Obtained.Value = false
	script.Parent.Visible = false
end

function Activate(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.Q then
	if script.Parent.Obtained.Value == true then
		script.Parent.Activet.Value = true
		script.P:Play()
		sheildoff()
		script.Click:Play()
		script.Electro:Play()
		script.Sap:Play()
		local Forcefield = Instance.new("ForceField")
		Forcefield.Parent = script.Parent.Parent.Parent.Parent.Character
		wait(15)
		Forcefield:Destroy()
		script.Sap:Stop()
		script.Click:Play()
		script.Parent.Activet.Value = false


	end
end
end

if script.Parent.Obtained == nil then 
repeat wait() until script.Parent.Obtained
end 
script.Parent.Obtained.Changed:connect(sheildon)

game:GetService("UserInputService").InputBegan:connect(Activate)

1 answer

✓ Accepted answer

The script may be running before the player is actually inserted into the game, therefore it wouldn't exist which is why it works in studio as studio loads instantly, try this instead:

 script.Parent:WaitForChild("Obtained").Value = false

In this case we wait for the child "Obtained" to actually load there.

2 comments

0

Thanks

0

No Problem.

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