So im making a custom hotbar script for my fighting game and im getting a strange error when getting to update the hotbar icons
The error itself is: “Unable to cast string to int64”
Heres my code
The error is on line 3
local function updatehotbar()
for i,v in pairs(hotbarSlots:GetChildren()) do
hotbar[v].SlotIcon.Image = "rbxassetid://" .. v.Icon.Value -- String value with the image id
hotbar[v].CurrentSlot = v.Value
end
end
for i,v in pairs(hotbarSlots:GetChildren()) do
v.Changed:Connect(updatehotbar)
v.Icon.Changed:Connect(updatehotbar)
end
--// Inventory
local keybinds = {
['1'] = "One",
['2'] = "Two",
['3'] = "Three",
['4'] = "Four",
['5'] = "Five",
}
local hotbarSlots = plr.Data:WaitForChild("Hotbar")
local hotbar = plr.PlayerGui["HUD"].GearHotbar:WaitForChild("HotbarFrame")
local function updatehotbar()
for i,v in pairs(hotbarSlots:GetChildren()) do
hotbar[v].SlotIcon.Image = "rbxassetid://" .. v.Icon.Value
hotbar[v].CurrentSlot = v.Value
end
end
for i,v in pairs(hotbarSlots:GetChildren()) do
v.Changed:Connect(updatehotbar)
v.Icon.Changed:Connect(updatehotbar)
end
v is like, the variable on for i,v in pairs that i did, hotbarSlots is a folder that has the values of each hotbar slots, like, there are 5 values in it named from 1 to 5 which are the same names as the hotbar slots in the UI, idk if u could understand but i can try to explain it better