I am trying to make a script that lets you get a award by using a chat command, and i'm using a RemoteEvent to do it. The problem is I get the " Unable to cast Instance to int" on line 8 of the second script.
LOCAL SCRIPT:
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://636749560"
local animtrack = nil
local canplay = true
local playe = game.Players.LocalPlayer
local char = playe.Character
local badgeid = 637991953
local id = playe.userId
local Lighting = game.Lighting
local Event = Lighting:WaitForChild("RemoteEvent")
function processCommand(message,recipient)
if message == "/e dab" then
print("part1")
if canplay then
canplay = false
animtrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation)
animtrack:Play()
-- Call to the server
-- We're going to give it some arguments that the AwardBadge function needs
-- So it needs the UserID and BadgeID
Event:FireServer(playe.UserId, badgeid) -- Fires the arguments to the server
print("event fired")
canplay = true
end
end
end
playe.Chatted:connect(processCommand)
SERVER SCRIPT:
local badgeService = game:GetService("BadgeService")
-- Set up the RemoteEvent (It will be in Lighting)
local Lighting = game.Lighting
local Event = Lighting:WaitForChild("RemoteEvent")
function awardBadge(id, badgeid) -- The function in which awards the player
print("awarding")
badgeService:AwardBadge(id, badgeid) -- Awards the player - BOOM! :D
print("awarded")
end
Event.OnServerEvent:connect(awardBadge) -- This listens to when the :FireServer() is called
Also, the tips are there because it was from someone who helped me earlier get this far. Thanks!

6 comments
BTW Remote Event is already in lighting
On line 23 of the localscript, change 'playe.UserId' to 'id' and see what happens
@qMeta It still doesn't work.
Possibly put the animation somewhere... so add a line after you give the animation its id and put 'animation.Parent = game.Players.LocalPlayer'
Change the function to "badgeService:AwardBadge(-NEWLINE- id, -NEWLINE- badgeid)" to see wich part of the line errors.
Line 23 should be userId