How do I fix this regen script?

So, my script didn’t work for the GetRankInGroup part but the gamepass one is working. I want it to both for If the player owns that gamepass and if the player rank is above 100.

Here is the script:

model = script.Parent.Parent.Jetski --Indicates that the script interacts with the model the button is grouped with.

local MarketplaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local GamepassID = 14217559
local groupId = 8402934
local minRank = 100


backup = model:Clone()
enabled = true

function regenerate(player)
	if not MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then return end
	if enabled then
		model:Destroy()

		wait(3)--

		model = backup:Clone()
		model.Parent = game.Workspace
		model:MakeJoints()
		if player:GetRankInGroup(groupId) >= minRank then
			if enabled then
				model:Destroy()
				
				wait(3)--
				
				model = backup:Clone()
				model.Parent = game.Workspace
				model:MakeJoints()
			end
		end
	end
end

local ClickDetector = Instance.new("ClickDetector", script.Parent)

ClickDetector.MouseClick:Connect(regenerate)
1 Like

This line stops the function if the player doesn’t own the gamepass. So if the player doesn’t have the gamepass then it never checks the rank.

local model = script.Parent.Parent.Jetski --Indicates that the script interacts with the model the button is grouped with.

local MarketplaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local GamepassID = 14217559
local groupId = 8402934
local minRank = 100


local backup = model:Clone()
local enabled = true

function regenerate(player)
    if not MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) and not (player:GetRankInGroup(groupId) >= minRank) then
        return
    end

    if enabled then
        model:Destroy()

        task.wait(3)

        model = backup:Clone()
        model.Parent = workspace
        model:MakeJoints()
        model:Destroy()
				
        task.wait(3)
				
        model = backup:Clone()
        model.Parent = workspace
        model:MakeJoints()
    end
end

local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = script.Parent

ClickDetector.MouseClick:Connect(regenerate)

does this work?

Let me try it right now. I’ll tell you if it works or not.