how would I make this a model?
-- -- Change these values to match your game's badge IDs and settings
local REQUIRED_BADGES = {123, 456, 789}
local FINAL_BADGE_ID = 999
local LIGHT_COLORS = {
Color3.fromRGB(255, 0, 0), -- Red for 0 badges
Color3.fromRGB(255, 255, 0), -- Yellow for 1 or 2 badges
Color3.fromRGB(0, 255, 0) -- Green for all 3 badges
}
local LIGHT_INTENSITY = 10
local LIGHT_RANGE = 15
local LIGHT_FADE_TIME = 1
local FLOAT_TIME = 3
local PEDASTAL_SOUND_ID = "rbxassetid://123456789" -- Replace with your own sound effect ID
local badgeService = game:GetService("BadgeService")
local pedestal = script.Parent
local trigger = pedestal:FindFirstChild("Trigger")
local pedestalLight = pedestal:FindFirstChild("PedestalLight")
local pedestalSound = pedestal:FindFirstChild("PedestalSound")
-- Function that returns the number of required badges the player owns
function getBadgeCount(player)
local count = 0
for i, badgeId in ipairs(REQUIRED_BADGES) do
if badgeService:UserHasBadgeAsync(player.UserId, badgeId) then
count = count + 1
end
end
return count
end
-- Function that updates the pedestal light based on the player's badge count
function updatePedestalLight(player)
local badgeCount = getBadgeCount(player)
if pedestalLight then
local color = LIGHT_COLORS[badgeCount + 1]
pedestalLight.Color = color
pedestalLight.Brightness = LIGHT_INTENSITY
pedestalLight.Range = LIGHT_RANGE
pedestalLight:TweenSize(UDim2.new(1, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, LIGHT_FADE_TIME)
end
end
-- Function that floats the player in the air and awards the final badge
function floatPlayer(player)
if pedestalSound then
local sound = Instance.new("Sound", workspace)
sound.SoundId = PEDASTAL_SOUND_ID
sound:Play()
end
local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
local rootPart = player.Character:FindFirstChild("HumanoidRootPart")
if rootPart then
local startPosition = rootPart.Position
local endPosition = pedestal.Position + Vector3.new(0, 5, 0)
local tween = game:GetService("TweenService"):Create(rootPart, TweenInfo.new(FLOAT_TIME), {Position = endPosition})
tween:Play()
tween.Completed:Connect(function()
badgeService:AwardBadge(player.UserId, FINAL_BADGE_ID)
end)
end
end
end
-- Event that updates the pedestal light when the player's badges change
badgeService.UserBadgeChanged:Connect(function(player, badgeId, isAwarded)
updatePedestalLight(player)
end)
Event that floats the player and awards the final badge if they own all the required badges
trigger.Touched:Connect(function(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player and getBadgeCount(player) == #REQUIRED_BADGES then
floatPlayer(player)