Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years 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 548 — 4y

1 answer

Log in to vote
0
Answered by
174gb 290 Moderation Voter
4 years 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