so i have this script where, if you click on a part, it will show an ending screen and then award you the badge.
but, it doesnt work. the badge doesnt award.
it gives me the error “unable to cast int64”
local TweenService = game:GetService("TweenService")
local badgeservice = game:GetService("BadgeService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage.Events
local plate = game.Workspace:WaitForChild("Plate")
local cd = plate.ClickDetector
local folder = plate.Placement.Items
local sound = game.Workspace.SFX["splat.wav"]
local function checkForItem(player)
local backpack = player.Backpack
for _,v in pairs(backpack:GetChildren()) do
if v:IsA("Tool") then
print("Player has a tool! Detecting if it's purchased or not!")
if v.Purchased.Value == false then
print("You need to purchase the item first!")
else
v.Parent = plate.Placement.Items
v.Handle.Position = Vector3.new(plate.Placement.TP.Position)
print("Player has purchased item! Giving ending..")
end
end
end
end
function GiveEnding(player)
for _,v in pairs(folder:GetChildren()) do
if v:IsA("Tool") then
wait(0.5)
Events.GiveEnding:FireServer(player, 4049146362969843, "nyum")
end
end
end
function EndingScreen(player)
for _,v in pairs(folder:GetChildren()) do
if v:IsA("Tool") then
print("There is something inside of the folder!")
wait(0.5)
script.Parent.Visible = true
local newpos = UDim2.new(-0.001, 0, -0, 0)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)
local tween = TweenService:Create(script.Parent, tweenInfo, {Position = newpos})
tween:Play()
wait(2)
if v.name.Value == "Burger" then
script.Parent.EndingName.Text = "Burger"
script.Parent.Desc.Text = "nyum"
script.Parent["Ending:"].Visible = true
sound:Play()
wait(2)
script.Parent.EndingName.Visible = true
sound:Play()
wait(3)
sound:Play()
script.Parent.Desc.Visible = true
end
end
end
end
cd.MouseClick:Connect(function(plr)
checkForItem(plr)
GiveEnding(plr)
EndingScreen(plr)
end)
here is the script (sorry, its long) and here is the script that awards the badge
local badgeservice = game:GetService("BadgeService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage.Events
Events:FindFirstChild("GiveEnding").OnServerEvent:Connect(function(plr, badgeId, message)
badgeservice:AwardBadge(plr.UserId, badgeId)
wait(5)
plr:Kick(message)
end)
the one that awards the badge is a serverscript in serverscript service.
the one that does the ending screen is a local script inside of a frame in startergui.
ive tried changing it to a server script, but it still doesnt award the badge, yet, it doesnt give the error.
plz help! idk what im doing wrong