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

Image id dosen't change?

Asked by 4 years ago
Edited 4 years ago

I am trying to make inventory so once player gets value 1 he gets an item but the image dosen't show up once i have i item

local Slot1 = script.Parent.Slot1
local Slot2 = script.Parent.Slot2

while true do
    wait(1)
if Slot1.Value == 1 then
    Slot1.Image = ("http://www.roblox.com/asset/?id=183584653")
else
    Slot1.Image = ("http://www.roblox.com/asset/?id=1884857885")
end

if Slot2.Value == 1 then
    Slot2.Image = ("http://www.roblox.com/asset/?id=183584653")
else
    Slot2.Image = ("http://www.roblox.com/asset/?id=1884857885")
    end
    wait(1)
end

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

its very unpractical to put it in a while loop. Try using events instead:

local Slot1 = script.Parent.Slot1 
local Slot2 = script.Parent.Slot2
local Slot1Check = --Create an IntValue
local Slot2Check = --Create another IntValue

Slot1Check.Changed:Connect(function()
if Slot1Check.Value == 1 then--[[Also, Slot1 and Slot2 don't have a Value (At least from what we can see). So you must create Another Variable.]]
    Slot1.Image = ("http://www.roblox.com/asset/?id=183584653")
else
    Slot1.Image = ("http://www.roblox.com/asset/?id=1884857885")
end
end)

Slot2Check.Changed:Connect(function()
if Slot2Check.Value == 1 then
    Slot2.Image = ("http://www.roblox.com/asset/?id=183584653")
else
    Slot2.Image = ("http://www.roblox.com/asset/?id=1884857885")
end
end)
0
Line 3 & 4 you shouldn't put = Nguyenlegiahung 1091 — 4y
Ad

Answer this question