I need help with something- I want to make a script check if you own a badge and then load another script into workspace if you do own the badge, and then kick you if you do not own it. This is for a ‘challenge’ type game I am making.
I have not gotten any errors at all, but it just will not kick you for not owning the badge and will just load the script anyway.
I am a pretty average scripter and have little to no idea about what I am doing. I got some help from a friend on this script but they also had no idea so any help is appreciated!
(AND YES I did change the BadgeId in the actually script, and I made sure I did not own the badge before testing it.)
local BanSave = dss:GetDataStore("BanSave")
local BadgeService = game:GetService("BadgeService")
local BadgeId = 2124545440
local BanReason = "You need to finish the challenge first!"
game.Players.PlayerAdded:Connect(function(player)
local IsBanned = Instance.new("BoolValue")
IsBanned.Name = "IsBanned"
IsBanned.Parent = player
local IsBanned = true
local RetrievedData
local Retrieved, failed = pcall(function()
RetrievedData = BanSave:GetAsync(player.UserId, player.IsBanned.Value)
end)
if Retrieved then
player.IsBanned.Value = RetrievedData
end
if BadgeService:UserHasBadgeAsync(player.UserId, BadgeId) then
player.IsBanned.Value = false
end
if player.IsBanned.Value == true then
player:Kick(BanReason)
elseif
player.IsBanned.Value == false then
wait(0.2)
local instert = game:GetService("InsertService"):LoadAsset(13732732878)
instert.Parent = workspace
end
end)