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

why does nothing happen when i use an if image == () statement?

I created an if statement that went like this and is used for a custom inventory button

script.Parent.MouseButton1Click:Connect(function()
	
	if script.Parent.Image == "http://www.roblox.com/asset/?id=1333146830" then
		script.Parent.Parent.Frame.Visible = true
		script.Parent.Parent.Frame.itemname.Text = "AzureSword"
		script.Parent.Parent.Frame.item.Image = "http://www.roblox.com/asset/?id=1333146830"
	end 
end)

when I click on this image button the frame doesnt become visible and nothing happens even when the image is accurate

1 comment

0

Then the condition isn't met. Check if that value is rbxassetid://1333146830 instead. Print the value of script.Parent.Image before the if-statement to verify

1 answer

✓ Accepted answer

When you change the id of a imageLabel/Button, the id gonna be "rbxassetid://SomeIdHere".

So your script would be this

script.Parent.MouseButton1Click:Connect(function() 
    if script.Parent.Image == "rbxassetid://1333146830" then --Correct format
      script.Parent.Parent.Frame.Visible = true
      script.Parent.Parent.Frame.itemname.Text = "AzureSword"
      script.Parent.Parent.Frame.item.Image = "rbxassetid://1333146830"
    end
end)

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