Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why doesnt the gui go away if you dont have the gamepass?

Asked by 7 years ago
Edited 7 years ago
local id = 1324880817
local Player = game.Players.LocalPlayer
game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:Connect(function(char)

if game:GetService('GamePassService'):PlayerHasPass(plr,id)then
    Player.StarterGui.RadioGui.Button.Visible = true
else
    Player.StarterGui.RadioGui.Button.Visible = false
end
end)
end)

Error attempt to index upvalue 'Player' (a nil value)

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

Okay so, for one, you don't need the second line. For two, a player doesn't have a StarterGui in them, they have a PlayerGui

For the differences between PlayerGui's and StarterGui's, click here

The script I'm going to give is for a Server Script. Everything new that will be added will be explained.

local id = 1324880817
local Players = game:GetService("Players") -- Gets the player service

Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        local RadioGui = plr.PlayerGui:WaitForChild("RadioGui") --Waits for the gui so there are no errors
        if RadioGui then --Makes sure that the gui is actually there
            local Button = RadioGui:WaitForChild("Button") --Waits for the button
            if Button then --Checks if the button is actually there
                if game:GetService('GamePassService'):PlayerHasPass(plr,id) then
                    Button.Visible = true
                else
                    Button.Visible = false
                end
            end
        end
    end)
end)

Hope that this helped, make sure to mark this as resolved if it did!

0
thank you EpicAshtonTheBoy 33 — 7y
0
Your welcome. superhudhayfa 39 — 7y
Ad

Answer this question