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

How do I make it so that the weapon GUI is only open to people in that group?

Asked by 5 years ago

This is my basic script. (I know the false and true should be switched. I was just testing if it worked.) It's still showing up to me, though, and I'm in that group..

 if (player:IsInGroup(3491785) == true) then

game.StarterGui.StatsBar.Visible = false

else

game.StarterGui.StatsBar.Visible = true

end
0
use PlayerGui, not StarterGui theking48989987 2147 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago
Edited by evaera 5 years ago

Once the game starts running, starter gui clones everything to the players playergui, so thats why its not working. Try using this:

lua if (player:IsInGroup(3491785) == true) then game.PlayerGui.StatsBar.Visible = false else game.PlayerGui.StatsBar.Visible = true end

0
Thats not what I meant, PlayerGui isn't a child of the DataModel(game), theking48989987 2147 — 5y
0
You want to do "game.Players.LocalPlayer.PlayerGui.StatusBar.Visible" songboy50 77 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

I think it's the true that's affecting it

Try this

 if player:IsInGroup(3491785) then
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

We'll change

if (player:IsInGroup(3491785) == true) then
   game.StarterGui.StatsBar.Visible = false
   else
   game.StarterGui.StatsBar.Visible = true
end

To

local Player = game:GetService("Players").LocalPlayer

if Player:IsInGroup(3491785) then
   Player.PlayerGui.StatsBar.Visible = false
   else
   Player.PlayerGui.StatsBar.Visible = true
end

Basically you're not correctly defining stuff like the player and you're changing the StarterGui which doesn't update to the player live.

0
remove the game. on the second script and you're good theking48989987 2147 — 5y
0
don't forget for the players service, its best to retrieve it with :GetService("Players") SerpentineKing 3885 — 5y
0
Oh yeah I fixed it. songboy50 77 — 5y

Answer this question