I have a remote event in replicated storage, and I want to make a gui pop up only for the players who have the gamepass, this script works in studio but not in game because i think you can't get the playergui on a live server or something like that. I don't really understand
I put a surface gui in the startergui and put it's adornee on a part, here are the scripts
i made a value that changes depending if the player has the gamepass or not, this is the script in the startergui under a number value when you touch a part(it's a server script)
local PassId = 4920137
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local BadgeService = game:GetService("MarketplaceService")
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("musicplayer15")
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:UserOwnsGamePassAsync(player.UserId, PassId) then
if not debounce then
debounce = true
script.Parent.Value=10
wait(5)
debounce = false
end
end
end
end)
this is the script under that part that i mentioned earlier:
local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("betaremote")
local radio = game.Workspace:WaitForChild("radio1")
local players = game:GetService("Players")
local debounce = false
script.Parent.Touched:Connect(function(part)
local plr = players:GetPlayerFromCharacter(part.Parent)
if plr then
if not debounce then
debounce = true
remote:FireClient(plr)
wait(1)
debounce = false
end
end
end)
this is the local script in the startergui and it's in the surface gui (it reads the value in the startergui)
local remote = game.ReplicatedStorage:WaitForChild("betaremote")
remote.OnClientEvent:Connect(function()
if script.Parent.Parent.Value.Value == 10 then
script.Parent.Enabled=true
end
end)

1 comment
Server Scripts do not run in PlayerGui