What am I doing wrong? I am super new to the scripting world as you can see lol & I’m trying to make this UI Gradient enabled if you’re a certain role in my roblox group.
This is the script
This is the location of the script highlighted in blue.
What am I doing wrong? I am super new to the scripting world as you can see lol & I’m trying to make this UI Gradient enabled if you’re a certain role in my roblox group.
This is the script
This is the location of the script highlighted in blue.
You need to clone the UI into the character’s head. You can then disable it by referencing the cloned UI. It would help if you pasted the code instead, so I don’t have to type it out manually.
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAppearanceLoaded:Connect(function(character)
if plr:IsInGroup(groupId) and plr:GetRankInGroup(groupId) == 255 then
UIGradient.Enabled = true
end
end)
end)
I really appreciate your help!
You forgot half the code. It would help if you also weren’t using abbreviated variable names like “plr”, it only makes it harder for you and others to read, with no benefit.
I just realized you gave me the OwnerScript code too, can you give me the LoadRole code?
local groupId = 33088774 – Group ID here
local MarketPlaceService = game:GetService(“MarketplaceService”)
local gamePassId = 668843131
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAppearanceLoaded:Connect(function(character)
local roleSuccess, role = pcall(function() return plr:GetRoleInGroup(groupId) end)
if roleSuccess and role then
local gui = script.TextName:Clone()
local check = plr.Character
local UIGradient = gui.NameLabel.UIGradient
if check~=nil then
local find = check:FindFirstChild("Head")
if find ~= nil then
gui.Parent = find
gui.NameLabel.Text = plr.Name
gui.RankLabel.Text = role
if MarketPlaceService:UserOwnsGamePassAsync(plr.UserId, gamePassId) then
UIGradient.Enabled = true
end
end
end
end
end)
end)
just sent the code of LoadRole. I already have a UIGradient for “NameLabel” and it works fine.
Get rid of your owner script and replace LoadRole with this script:
local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")
local gamePassId = 668843131
local groupId = 33088774
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local head = character:WaitForChild("Head")
local gui = script.TextName:Clone()
gui.NameLabel.Text = player.Name
gui.RankLabel.Text = player:GetRoleInGroup(groupId)
gui.Parent = head
local nameUIGradient = gui.NameLabel.UIGradient
local rankUIGradient = gui.RankLabel.UIGradient
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamePassId) then
nameUIGradient.Enabled = true
end
if player:GetRankInGroup(groupId) == 255 then
rankUIGradient.Enabled = true
end
end)
end)
Spend some time to understand it, and if you have any questions, feel free to ask.
(:IsInGroup
is useless by the way, because we are already checking for their rank, which returns 0 if they aren’t in the group)
tysm!!! ur code seriously helped me i know this was probably simple for you but I appreciate u taking the time to help me!!!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.