Does anyone know why my accessory equiper isnt working

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)

heres the layout
image

image

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)

hope this helps

1 Like

thanks for the assist!
but i was able to solve it a while ago i just forgot to close the post :smiley:

everything i did was right but the issue was in the localscript i was doing ToolGiverUI instead of AccessoryGiverUI :smiley:

oh okay good luck on your game though!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.