Unable to cast Instance to int64

NOTE I know there are a lot of posts on this, but none of them really helped me, I couldn’t understand the solution for a few of them, sorry, even if there was a good solution for my situation, I wouldn’t have/didn’t understand so /shrug.

So I am creating a mask system, and I have localscript which will listen to a mouseclick, which will then fire a remote event with 2 parameters; player and MaskId. Thanks.

LOCALSCRIPT

local Part = game.Workspace.Part.ClickDetector

local RepStorage = game:GetService("ReplicatedStorage")

local Event = RepStorage:WaitForChild("WearMask")

local player = game.Players.LocalPlayer

Part.MouseClick:Connect(function()

Event:FireServer(player, 4753644287)

end)

EVENT RECIEVER (SERVER)

local RepStorage = game:GetService("ReplicatedStorage")

local InsertService = game:GetService("InsertService")

local Event = RepStorage:WaitForChild("WearMask")

Event.OnServerEvent:Connect(function(player, MaskId)

repeat wait() until player.Character

local AssetLoaderHat = InsertService:LoadAsset(MaskId)

local AssetLoaderHatChildren = AssetLoaderHat:GetChildren()

for i,v in pairs(AssetLoaderHatChildren) do

print(v.Name.."is being worn by"..player.Name)

v.Parent = player.Character

end

end)

Apologies, I don’t know what happened to the indentation, but I guess you can see what was happening in the script, I’ll try and fix it.

Roblox already knows which player fired the remote.

So just change that to

Event:FireServer(4753644287)
2 Likes