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
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.
Create a RemoteFunction place it in RelicatedStorage
Put this code above your main function:
function GetImageID(ID)
local NewID = RemoteFunction:InvokeServer(ID)
return(NewID)
end
After imagelabel.image = call the function above and put the ID in the parentheses.
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
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”