What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Couldn’t find anything to help.
I have a normal script placed into StarterCharacterScripts, its active but not working.
local Player = game.Players.LocalPlayer
local RequiredRank = "Rank2"
local Barrier = workspace:WaitForChild('Rank1_Barrier')
local leaderstats1 = Player:WaitForChild('leaderstats')
rank = script.leaderstats1.Rank
game.Players.PlayerAdded:Connect(function(Player)
if rank.Value >= RequiredRank then
Barrier:Destroy()
end
end)
If anyone could help that would be greatly appreciated
local Player = game.Players.LocalPlayer
local rank = Player:WaitForChild('leaderstats'):WaitForChild("Rank")
local RequiredRank = "Rank2"
local Barrier = workspace:WaitForChild('Rank1_Barrier')
--use this if statement inside of a click event or touch event
if rank.Value == RequiredRank then
Barrier:Destroy()
end
this should work if everything is defined properly.
also you should consider invoking the server with a remote function to do a rank check and if the server returns true, destroy the barrier on the client side.
local Player = game.Players.LocalPlayer
local rank = Player:WaitForChild('leaderstats'):WaitForChild("Rank")
local RequiredRank = "Rank2"
local Barrier = workspace:WaitForChild('Rank1_Barrier')
--use this if statement inside of a click event or touch event
if rank.Value == RequiredRank then
Barrier:Destroy()
end
Comparing “Rank1” and “Rank2” will not work in the way that you want it to.
You could either:
Use string.sub to compare the numbers of the Rank leaderstat
or
Turn the leaderstat into a NumberValue and use that.
I’ll use string.sub for this.
Try this:
-- Localscript
local Player = game.Players.LocalPlayer
local RequiredRank = "Rank2"
local Barrier = game.Workspace:WaitForChild("Rank1_Barrier")
local leaderstats1 = Player:WaitForChild("leaderstats")
local Rank = leaderstats1.Rank
local RankNumeral = tonumber(string.sub(5, Rank.Value))
local RequiredRankNumeral = tonumber(string.sub(5, RequiredRank))
if RankNumeral >= RequiredRankNumeral then
Barrier:Destroy()
end