New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 3 months ago

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

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 pidgey 538 — 3mo

1 answer

Log in to vote
0
Answered by
sO_Ov 150
3 months ago

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)
Ad

Answer this question