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

server script in playergui works in studio but not in game?

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

0

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.

1 answer

If this "script" is in a GUI, make sure it is a local one.

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