my script keeps giving me this error
Unable to cast string to int64
does anyone know whats wrong
im using a localscript, a script and a remote event
heres the scripts code
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr, accessory)
game:GetService("InsertService"):LoadAsset(accessory):FindFirstChildWhichIsA("Accessory").Parent = plr.Character
print(plr.Name .. " has been given asset id " .. accessory .. ", the name of the accessory is " .. game:GetService("InsertService"):LoadAsset(accessory):FindFirstChildWhichIsA("BackpackItem").Name)
end)
and heres the local script code
local box = script.Parent.Parent.TextBox
script.Parent.MouseButton1Click:Connect(function(plr)
script.Parent.RemoteEvent:FireServer(game.Players.LocalPlayer.PlayerGui.ToolGiverUI.Frame.TextBox.Text)
end)
im pretty sure this is because the asset id’s from roblox are in the int64 type and the text within the gui is a string therefore youd need to convert it, not an expert at this but try using tonumber()
heres what it would look like
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr, accessory)
game:GetService("InsertService"):LoadAsset(tonumber(accessory)):FindFirstChildWhichIsA("Accessory").Parent = plr.Character
print(plr.Name .. " has been given asset id " .. accessory .. ", the name of the accessory is " .. game:GetService("InsertService"):LoadAsset(accessory):FindFirstChildWhichIsA("BackpackItem").Name)
end)