Help with changes an image with a script

hello. the following script works fine without any errors or flaws but for some reason the image i want to change is not changing. im not seeing any reasons so can you take a look at it?

script is heads or tails and the image is suppose to be a coin flipping animation. it should work but images wont change

script:

local imagehead14 = "http://www.roblox.com/asset/?id=8065738734"
local imagehead13 = "http://www.roblox.com/asset/?id=8065735589"
local imagehead12 = "http://www.roblox.com/asset/?id=8065737551"
local imagehead1 = "http://www.roblox.com/asset/?id=8065734219"
local imagetail14 = "http://www.roblox.com/asset/?id=8065739974"
local imagetail13 = "http://www.roblox.com/asset/?id=8065742524"
local imagetail12 = "http://www.roblox.com/asset/?id=8065741478"
local imagetail1 = "http://www.roblox.com/asset/?id=8065743918"


local npc = script.Parent:WaitForChild("TextLabel")
local guiframe = script.Parent
local imagelabel = script.Parent:WaitForChild("ImageLabel")
local bet = imagelabel.Status:WaitForChild("Bet")
local tails = bet:WaitForChild("Tails")
local heads = bet:WaitForChild("Heads")
local ubet = bet:WaitForChild("YouBet")
local cs = bet:WaitForChild("coinSide")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
local cd = true

function main()
	local chance = math.random(1, 30)
	if chance >= 14 and cs.Value == "Heads" then
		imagelabel.Image = imagetail1
		wait(0.1)
		imagelabel.Image = imagetail12
		wait(0.1)
		imagelabel.Image = imagetail13
		wait(0.1)
		imagelabel.Image = imagetail14
		wait(0.1)
		imagelabel.Image = imagehead1
		wait(0.1)
		imagelabel.Image = imagehead12
		wait(0.1)
		imagelabel.Image = imagehead13
		wait(0.1 )
		imagelabel.Image = imagehead14
		print("You Won!")
		cash.Value = cash.Value + tonumber(ubet.Text)
	elseif chance >= 14 and cs.Value == "Tails" then
		imagelabel.Image = imagehead1
		wait(0.1)
		imagelabel.Image = imagehead12
		wait(0.1)
		imagelabel.Image = imagehead13
		wait(0.1 )
		imagelabel.Image = imagehead14
		wait(0.1)
		imagelabel.Image = imagetail1
		wait(0.1)
		imagelabel.Image = imagetail12
		wait(0.1)
		imagelabel.Image = imagetail13
		wait(0.1)
		imagelabel.Image = imagetail14

		print("You Won!")
		cash.Value = cash.Value + tonumber(ubet.Text)
	elseif chance <= 14 and cs.Value == "Tails" then
		imagelabel.Image = imagetail1
		wait(0.1)
		imagelabel.Image = imagetail12
		wait(0.1)
		imagelabel.Image = imagetail13
		wait(0.1)
		imagelabel.Image = imagetail14
		wait(0.1)
		imagelabel.Image = imagehead1
		wait(0.1)
		imagelabel.Image = imagehead12
		wait(0.1)
		imagelabel.Image = imagehead13
		wait(0.1 )
		imagelabel.Image = imagehead14
		print("You Lost!")
		cash.Value = cash.Value - tonumber(ubet.Text)
	elseif chance <= 14 and cs.Value == "Heads" then
		imagelabel.Image = imagehead1
		wait(0.1)
		imagelabel.Image = imagehead12
		wait(0.1)
		imagelabel.Image = imagehead13
		wait(0.1 )
		imagelabel.Image = imagehead14
		wait(0.1)
		imagelabel.Image = imagetail1
		wait(0.1)
		imagelabel.Image = imagetail12
		wait(0.1)
		imagelabel.Image = imagetail13
		wait(0.1)
		imagelabel.Image = imagetail14
		print("You Lost!")
		cash.Value = cash.Value - tonumber(ubet.Text)
	end
	wait(2)
	cd = true
	imagelabel.Image = ""
end

heads.MouseButton1Click:Connect(function()
	if cd == true and tonumber(ubet.Text) ~= nil then
		if tonumber(ubet.Text) <= cash.Value and tonumber(ubet.Text) ~= 0 then
			cd = false
			cs.Value = "Heads"
			bet.Text = "Heads"
			main()
		end
	end
end)

tails.MouseButton1Click:Connect(function()
	if cd == true and tonumber(ubet.Text) ~= nil then
		if tonumber(ubet.Text) <= cash.Value and tonumber(ubet.Text) ~= 0 then
			cd = false
			cs.Value = "Tails"
			bet.Text = "Tails"
			main()
		end
	end
end)

notes
its a local script
image label is a variable on line 14

this may help:

links to all images:
local imagehead14 = “http://www.roblox.com/asset/?id=8065738734”

local imagehead13 = “http://www.roblox.com/asset/?id=8065735589”

local imagehead12 = “http://www.roblox.com/asset/?id=8065737551”

local imagehead1 = “http://www.roblox.com/asset/?id=8065734219”

local imagetail14 = “http://www.roblox.com/asset/?id=8065739974”

local imagetail13 = “http://www.roblox.com/asset/?id=8065742524”

local imagetail12 = “http://www.roblox.com/asset/?id=8065741478”

local imagetail1 = “http://www.roblox.com/asset/?id=8065743918”

Thank You!

2 Likes

Are you getting a warning saying “image failed to load”?

i edited the script since i realized those links are invalid but it still doesnt work – and no im not getting any errors it just isnt showing.

new script:

local imagehead14 = "https://www.roblox.com/library/8065738734/4B051671-A9F7-4645-B629-6540BD083C3F"
local imagehead13 = "https://www.roblox.com/library/8065737551/9A601A47-1859-4F5D-B2B7-47277AFD9BA7"
local imagehead12 = "https://www.roblox.com/library/8065735589/16046D7A-57FA-4810-9DAD-3A005D5CABF6"
local imagehead1 = "https://www.roblox.com/library/8065734219/DFFC1914-62AB-4FE7-8234-300EFE2A33F6"
local imagetail14 = "https://www.roblox.com/library/8065739974/6FE94EBA-E74D-44ED-8E94-6DEA388ACD90"
local imagetail13 = "https://www.roblox.com/library/8065741478/020DE5A9-A473-4195-8E8C-D524E4AF4288"
local imagetail12 = "https://www.roblox.com/library/8065742524/8E4D9A56-9BF0-4731-AE5E-AF412FB81D3A"
local imagetail1 = "https://www.roblox.com/library/8065743918/70A74D65-AF8C-444F-9B01-1DDEAABF9D82"


local npc = script.Parent:WaitForChild("TextLabel")
local guiframe = script.Parent
local imagelabel = script.Parent:WaitForChild("ImageLabel")
local bet = imagelabel.Status:WaitForChild("Bet")
local tails = bet:WaitForChild("Tails")
local heads = bet:WaitForChild("Heads")
local ubet = bet:WaitForChild("YouBet")
local cs = bet:WaitForChild("coinSide")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
local cd = true

function main()
	local chance = math.random(1, 30)
	if chance >= 14 and cs.Value == "Heads" then
		imagelabel.Image = imagetail1
		wait(0.1)
		imagelabel.Image = imagetail12
		wait(0.1)
		imagelabel.Image = imagetail13
		wait(0.1)
		imagelabel.Image = imagetail14
		wait(0.1)
		imagelabel.Image = imagehead1
		wait(0.1)
		imagelabel.Image = imagehead12
		wait(0.1)
		imagelabel.Image = imagehead13
		wait(0.1 )
		imagelabel.Image = imagehead14
		print("You Won!")
		cash.Value = cash.Value + tonumber(ubet.Text)
	elseif chance >= 14 and cs.Value == "Tails" then
		imagelabel.Image = imagehead1
		wait(0.1)
		imagelabel.Image = imagehead12
		wait(0.1)
		imagelabel.Image = imagehead13
		wait(0.1 )
		imagelabel.Image = imagehead14
		wait(0.1)
		imagelabel.Image = imagetail1
		wait(0.1)
		imagelabel.Image = imagetail12
		wait(0.1)
		imagelabel.Image = imagetail13
		wait(0.1)
		imagelabel.Image = imagetail14

		print("You Won!")
		cash.Value = cash.Value + tonumber(ubet.Text)
	elseif chance <= 14 and cs.Value == "Tails" then
		imagelabel.Image = imagetail1
		wait(0.1)
		imagelabel.Image = imagetail12
		wait(0.1)
		imagelabel.Image = imagetail13
		wait(0.1)
		imagelabel.Image = imagetail14
		wait(0.1)
		imagelabel.Image = imagehead1
		wait(0.1)
		imagelabel.Image = imagehead12
		wait(0.1)
		imagelabel.Image = imagehead13
		wait(0.1 )
		imagelabel.Image = imagehead14
		print("You Lost!")
		cash.Value = cash.Value - tonumber(ubet.Text)
	elseif chance <= 14 and cs.Value == "Heads" then
		imagelabel.Image = imagehead1
		wait(0.1)
		imagelabel.Image = imagehead12
		wait(0.1)
		imagelabel.Image = imagehead13
		wait(0.1 )
		imagelabel.Image = imagehead14
		wait(0.1)
		imagelabel.Image = imagetail1
		wait(0.1)
		imagelabel.Image = imagetail12
		wait(0.1)
		imagelabel.Image = imagetail13
		wait(0.1)
		imagelabel.Image = imagetail14
		print("You Lost!")
		cash.Value = cash.Value - tonumber(ubet.Text)
	end
	wait(2)
	cd = true
	imagelabel.Image = ""
end

heads.MouseButton1Click:Connect(function()
	if cd == true and tonumber(ubet.Text) ~= nil then
		if tonumber(ubet.Text) <= cash.Value and tonumber(ubet.Text) ~= 0 then
			cd = false
			cs.Value = "Heads"
			bet.Text = "Heads"
			main()
		end
	end
end)

tails.MouseButton1Click:Connect(function()
	if cd == true and tonumber(ubet.Text) ~= nil then
		if tonumber(ubet.Text) <= cash.Value and tonumber(ubet.Text) ~= 0 then
			cd = false
			cs.Value = "Tails"
			bet.Text = "Tails"
			main()
		end
	end
end)

new links:
local imagehead14 = “4B051671-A9F7-4645-B629-6540BD083C3F - Roblox”
local imagehead13 = “9A601A47-1859-4F5D-B2B7-47277AFD9BA7 - Roblox”
local imagehead12 = “16046D7A-57FA-4810-9DAD-3A005D5CABF6 - Roblox”
local imagehead1 = “DFFC1914-62AB-4FE7-8234-300EFE2A33F6 - Roblox”
local imagetail14 = “6FE94EBA-E74D-44ED-8E94-6DEA388ACD90 - Roblox”
local imagetail13 = “020DE5A9-A473-4195-8E8C-D524E4AF4288 - Roblox”
local imagetail12 = “8E4D9A56-9BF0-4731-AE5E-AF412FB81D3A - Roblox”
local imagetail1 = “70A74D65-AF8C-444F-9B01-1DDEAABF9D82 - Roblox”

Can you provide a video of what exactly is happening?

i dont have a recording software but i could try my phone. and i already said
no errors. nothing happens. ill still record with my phone though.

Alright, it is just that there is not a lot to go off from here, like is the script a local script? Where is the GUI located?

Heres video

Look at screenshot i included in post

Its a local script in startergui

Stuff workin is script name by the way.

Okay, I think I figured it out.

Where you put imagelabel.Image = [Your ImageID] change it to imagelabel.Image = GetImageID([Your ImageID])

Then you need to add a function above that will fire a RemoteFunction that the server-side can access
The function should look like this:

function GetImageID(ID)
      local NewID = RemoteFunction:InvokeServer(ID)
      return(NewID)
end

A server-side script should fire when the RemoteFunction is invoked
The function should look like this:

function GetNewImageID(Player, ID)
	local assetInfo = MarketplaceService:GetProductInfo(decalId, Enum.InfoType.Asset)

	assert(assetInfo.IsPublicDomain)
	assert(assetInfo.AssetTypeId == Enum.AssetType.Decal.Value)

	local decal = InsertService:LoadAsset(decalId):FindFirstChildWhichIsA("Decal")
	return decal.Texture
end 

You have the URL in the wrong format, I know that Roblox has a page about this, but I currently don’t have it…

So i have to make a replicated event in replicated storage and a script then copy paste the code and call the replicated event in the local script? o is GetId() a built in thing

Create a function above your main function, I named it GetID, which will call a RemoteFunction, it must be a RemoteFUNCTION. You can place it in ReplicatedStorage if you want.

i guess the decal not even exist ig

look at my reply which i updated script

ok so give me steps of what to do numbering out
for example

  1. create remote function and name (name)

  2. create script in workspace

  3. paste this code in script (code)

  4. make a function (function) which you put above main function

  5. right this instead of imagelabel.image

it may help if you send a video with text or voice to give instruction but what i did above is just as OK

  1. Create a RemoteFunction place it in RelicatedStorage
  2. Put this code above your main function:

function GetImageID(ID)
      local NewID = RemoteFunction:InvokeServer(ID)
      return(NewID)
end

  1. After imagelabel.image = call the function above and put the ID in the parentheses.
  2. In a server-side script have this function:

function GetNewImageID(Player, ID)
	local assetInfo = MarketplaceService:GetProductInfo(decalId, Enum.InfoType.Asset)

	assert(assetInfo.IsPublicDomain)
	assert(assetInfo.AssetTypeId == Enum.AssetType.Decal.Value)

	local decal = InsertService:LoadAsset(decalId):FindFirstChildWhichIsA("Decal")
	return decal.Texture
end 

Call the function above when the RemoteFunction is invoked.

remote function is an unknown global. did you forget to define it?
marketplaceservice doesnt exist
insert service doesnt exist
decalId doesnt exist

also please give examples and be more specific since i typically dont ever use remote events so i dont know what this stuff is
.
for example is it:
imagelabel.image = RemoteFunction:InvokeServer(ID)
for every time i want to change an image?

also please stop saying terms like “server side” and just say make a script in workspace etc

please load your scripts in a workspace and test before giving becuase it has tons of errors or at least give me full scripts

when you give locations inside script tell me if its inside main script or outside main script. does it have end or not?

so far i have made a script in workspace that has

function GetNewImageID(Player, ID)
	local assetInfo = MarketplaceService:GetProductInfo(decalId, Enum.InfoType.Asset)

	assert(assetInfo.IsPublicDomain)
	assert(assetInfo.AssetTypeId == Enum.AssetType.Decal.Value)

	local decal = InsertService:LoadAsset(decalId):FindFirstChildWhichIsA("Decal")
	return decal.Texture
end

in it.

it may be useful if you can edit the script and just add on it to dispell confusion
ALL THE ERRORS WERE MENTIONED ABOVE

Hey an not on pc right now but look on thé image (Like the frame image) and look in propreties and if you see something Like ImageID you nead to change ImageNameHere.Image to ImageNameHere.ImageID =

im confused by this statement. you want me to change the name property of something to this?

i suggest you say things like
in the script
instead of
and avoid things like
property
server side
client side
etc

You should have put rbxassetid://xxxxxxxxxx since it’s your own Image.

local imagehead14 = “rbxassetid://8065738734 ”

local imagehead13 = “rbxassetid://8065735589 ”

local imagehead12 = “rbxassetid://8065737551 ”

local imagehead1 = “rbxassetid://8065734219”

local imagetail14 = “rbxassetid://8065739974”

local imagetail13 = “rbxassetid://8065742524 ”

local imagetail12 = “rbxassetid://8065741478”

local imagetail1 = “rbxassetid://8065743918”