I am trying to make a button visible if a player joins a group, but every time if a player joins when they join the group, the button doesn’t shows. Rejoining Also wont work.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
if player:IsInGroup(33662799) then
TextButtonForAutoClicker.Visible = true
else
TextButtonForAutoClicker.Visible = false
end
end)
Are you doing this on a local script? You need to do it on the server and enable the button from there.
Also try to wait a bit because IsInGroup yields
is this on a localscript? if it is then you need to use game.players.localplayer to get the local player. also make sure the script is in starterplayerscripts so it actually runs. if it requires to be on server then put the same script but make the textbutton value in the playeradded function and set it to player.PlayerGui.ScreenGui.TextButtonForAutoClicker
A little issue I noticed is that you never assigned “TextButtonForAutoClicker” to an object.
local Player = game.Players.LocalPlayer
local TextButtonForAutoClicker = "path.to.autoclicker"
if Player:IsInGroup(33662799) == true then
TextButtonForAutoClicker.Visible = true
print("Player is in the group!")
else
TextButtonForAutoClicker.Visible = false
print("Player is NOT in the group!")
end
PLEASE CHANGE PATH.TO.AUTOCLICKER TO BE THE PATH TO THE BUTTON
Alright, I figured it out that why it doesn’t work for me, heres the fixed code:
script.Parent.MouseButton1Click:connect(function(Player)
if player:IsInGroup(33662799) then
print("Player on the group")
active = not active
script.Parent.Parent.BackgroundColor3 = Color3.new(0, 1, 0)
else
print("Player isnt on the group")
script.Parent.Parent.Parent.Parent.Alert.Frame.Visible = true
end
end)