Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make it give points to players in certin rank on group? (easy)

I need it to only run the points command if the player is in the group on a min of rank 3!

------------------
GroupIdenabled = true
--------------
GroupId == 6064323
min = 3

max = 10
	then
	
game.Players.PlayerAdded:connect(function(p)
local stats = Instance.new("IntValue", p)
stats.Name = "leaderstats"
local money = Instance.new("IntValue", stats)
money.Name = "Points"
money.Value = 0
while true do
wait(5)
money.Value = money.Value + 1
end
end)
end)

1 answer

✓ Accepted answer

Hello, JuzeyPlayz. You can do that by using the Player:GetRankInGroup(int64 groupId) function as it returns the rank interger. Also, use coroutines on while true do loops so that they don't stop the rest of the script from running and use local before creating a variable. Try this:

------------------
local GroupIdenabled = true
--------------
local GroupId = 6064323
local min = 3

local max = 10

game:GetService("Players").PlayerAdded:connect(function(p)
	local stats = Instance.new("IntValue", p)
	stats.Name = "leaderstats"
	local money = Instance.new("IntValue", stats)
	money.Name = "Points"
	money.Value = 0

	if p:GetRankInGroup(GroupId) <= 10 and p:GetRankInGroup(GroupId) >= 3 then
		coroutine.wrap(function()
			while true do
			wait(5)
			money.Value = money.Value + 1
			end
		end)()
	end
end)

I hope this helps you. Make sure you accept the answer if this helped you.

coroutine

5 comments

0

@youtubemasterWOW There is an error in the least end) on line 25 there is a red line and it says expected somthing please help.

0

I've edited it. Now try and see if it'll work.

0

Hey man it works thxs!

0

Np.

0

Ideally, you don't need a coroutine in this instance, as the code is very little. This code will still function properly without a coroutine.

This discussion is preserved as it was. New answers, comments, and votes are closed.