I have this script in the playergui and it's the child of a numbervalue, it works in studio but not in game, can anyone help me fix it?
local PassId = 2100404188
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
local MarketplaceService = game:GetService("MarketplaceService")
local pos = CFrame.new(47.855, 2.137, 104.632)
local getPlayerFromCharacter
local player
local debounce = false
local gamer = game.Workspace:WaitForChild("10hour")
getPlayerFromCharacter = function(model)
local plr = Players:GetPlayerFromCharacter(model)
if plr then
return plr
else
return nil
end
end
gamer.Touched:Connect(function(hit)
local player = getPlayerFromCharacter(hit.Parent)
if player then
if BadgeService:UserHasBadge(player.UserId, PassId) then
if not debounce then
debounce = true
script.Parent.Value=1
print("10 hour activated")
wait(1)
debounce = false
end
end
end
end)

1 comment
How would you change the playergui if nothing is connecting it to the local instance? A serverscript wouldn't work because players aren't loaded during the server instance, only after. Switch to using a localscript instead.