I wanted to make a button that would change the Image on and ImageLabel

The Script:

script.Parent.MouseEnter:Connect(function()
	script.Parent.ImageTransparency = 0.5
end)

script.Parent.MouseLeave:Connect(function()
	script.Parent.ImageTransparency = 0
end)

script.Parent.MouseButton1Click:Connect(function()
	local c = false
	local p = script.Parent.Parent.Parent.Main
	if c == false then
		c = true
		script.Parent.ImageLabel.Image = "rbxassetid://5015856792"
		p:TweenPosition(UDim2.new(0.5, -335, 0.5, -176), "Out", "Quint", 1.2)
	elseif c == true then
		c = false
		p:TweenPosition(UDim2.new(0.5, -335, 2, -176), "Out", "Quint", 1.2)
		script.Parent.ImageLabel.Image = "rbxassetid://5148052965"
	end
end)

The script works but the Image never loads! I tried using PreloadAsync but the wifi wasn't the problem because everytime i change the Image on Studio Mode it loads fine. If anyone can help that would be great!

6 comments

0

Have you already put the AssetId into an Image object to get the correct rbxassetid?

0

"http://www.roblox.com/asset/?id=" didnt work and "rbxassetid://" also didnt work

0

Does roblox give any errors? Is asset uploaded to roblox recently? Have you tried to use different picture ID? Are you using image ID or decal ID? Maybe use of image instead of decal may cause the problem

0

it doesnt show any errors, after clicking it just dissapears

0

i tried using different images, and it worked fine. so there must be a problem with the image. it was uploaded by me a few months ago. ill go check the image

0

i always try reuploading the same image, i dont know whats the problem, every picture works but not mine