Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

regular server script works in studio but not in game?

this script in the server works in studio but not in game, could someone tell me why? ( its in the server script service)

local BadgeService = game:GetService("BadgeService")
local PassId = 2100404188
local players = game:GetService("Players")
local xds = game.Workspace:WaitForChild("yess")
local debounce = false


players.PlayerAdded:Connect(function(plr)
	local player = game.Players:GetPlayerFromCharacter(plr.Parent)
	
		        if BadgeService:UserHasBadge(plr.UserId, PassId) then 
			
			plr.Backpack.storage.tenhourvalue.Value = 1
			print("10 hour activated")
	end
	
	end)


1 answer

✓ Accepted answer

You don't need this...

players.PlayerAdded:Connect(function(plr)
	local player = game.Players:GetPlayerFromCharacter(plr.Parent)
...

plr is already a player, what your doing is pointless since you

  1. Already have the player, and
  2. Would have to wait for the player's character

Incapaz Note: Use UserHasBadgeAsync instead of UserHasBadge because of new Badge updates.

2 comments

0

You should also mention UserHasBadge is broken because of the new badge updates. Tell OP to switch to UserHasBadgeAsync

0

Good point

This discussion is preserved as it was. New answers, comments, and votes are closed.