Clone object from serverstorage if you have badge on join?

Been trying to figure out a way to clone and object from serverstorage and have it appear in workspace when you join a game, here is what i’m working with but any time i test it, it does not work.

Can someone help me out?

local player = game.Players.LocalPlayer
local bs = game:GetService("BadgeService")


game.Players.PlayerAdded:Connect(function()
	local badgeId = 2126669305
	if bs:UserHasBadgeAsync(player.UserId,badgeId) then
		game.ServerStorage.Statue:Clone().Parent = game.Workspace
		print("test")
	end
end)
1 Like

Is this a script or a localscript?

I’ve tried both and they still don’t work

1 Like

Maybe try this?
Put this code in a script in ServerScriptService

local players = game:GetService("Players") -- normal scripts cant use LocalPlayer; It's localscript exclusive.
local bs = game:GetService("BadgeService")


players.PlayerAdded:Connect(function(plr) -- you can get the localplayer in a script easily via this exact function instead 
	local badgeId = 2126669305
	if bs:UserHasBadgeAsync(plr.UserId, badgeId) then
		game.ServerStorage.Statue:Clone().Parent = workspace
		print("test")
	end
end)

we could try a localscript instead if youre looking for the statue in serverstorage to only appear to the player with the badge.
image

Just what I was looking for thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.