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

[Answered] How can i give gear to a certain rank? [closed]

Asked by 10 years ago

I'm not all that great with lua so i have no idea what i'm doing but i want a certain rank to get gear and this is what i have. It doesn't seem to work and i have no idea why, I used this same method for Rank Colors.

GroupId = 1141758

UnrefinedRank = newPlayer:GetRankInGroup(GroupId)

function onPlayerEntered(newPlayer)

if UnrefinedRank = 254 then
     game.Lighting["Taser"]:Clone().Parent = newPlayer.StarterGear
end

if UnrefinedRank = 254 then
     game.Lighting["Baton"]:Clone().Parent = newPlayer.StarterGear
end
end
game.Players.PlayerAdded:connect(onPlayerEntered)

Locked by adark and TheMyrco

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
1
Answered by
TopDev 0
10 years ago

Try this!

GroupId = 1141758


game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:wait()
UnrefinedRank = player:GetRankInGroup(GroupId)
if UnrefinedRank >= 254 then
game.Lighting["Taser"]:Clone().Parent = player.StarterGear
game.Lighting["Baton"]:Clone().Parent = player.StarterGear
game.Lighting["Taser"]:Clone().Parent = player.Backpack
game.Lighting["Baton"]:Clone().Parent = player.Backpack
end
end)




0
Is your exact rank number 254, or is it higher? TopDev 0 — 10y
0
Okay, try the updated script. TopDev 0 — 10y
0
What about now? TopDev 0 — 10y
0
Did that work? TopDev 0 — 10y
View all comments (5 more)
0
It works, but what does the < do? because i only want a certain rank to have it Alpha_Toon 57 — 10y
0
I mean the > Alpha_Toon 57 — 10y
0
I just realized that i just had to change > to = to make it == Alpha_Toon 57 — 10y
0
Thanks Alpha_Toon 57 — 10y
0
I'd like to suggest looking into the GetRoleInGroup method. It returns the *name* of the rank the player has, rather than its value. adark 5487 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Alright, so the first thing I noticed wrong is your syntax.

GroupId = 1141758

UnrefinedRank = newPlayer:GetRankInGroup(GroupId)

function onPlayerEntered(newPlayer)

if UnrefinedRank == 254 then --One equals sign just means that a value is getting assigned to the object or variable. Use two equals signs to check if it's the same as.
     game.Lighting["Taser"]:Clone().Parent = newPlayer.StarterGear
end

if UnrefinedRank == 254 then
     game.Lighting["Baton"]:Clone().Parent = newPlayer.StarterGear
end
end
game.Players.PlayerAdded:connect(onPlayerEntered)