Error in script!

does anyone know what wrong with this script?

system = script.Parent

model = system.Box --

backup = model:Clone()

regen = system.Regen
game.Players.PlayerAdded:Connect(function(plr)
	
	local gamepassId = 148181594
	local market = game:GetService("MarketplaceService")


	function checkRegen()

		if regen.Value == 1 then

			if market:UserOwnsGamePassAsync(plr.UserId,gamepassId) then

				wait(1)

				model = backup:Clone()

				model.Parent = system

				model:MakeJoints()
				
			else
				market:PromptGamePassPurchase(plr, gamepassId)
			end

		end

	end
	
end)

regen.Changed:Connect(checkRegen)

this was the error, btw when I dont do the game pass thing it does work.

Attempt to connect failed: Passed value is not a function

1 Like

This the error?

What line is the error on? I am going to guess the connection although something else could be interfering outside.

yes the connect thing on the last line

Try :GetPropertyChangedSignal("Value")

I dont want to check the value

Okay? Use :GetPropertyChangedSignal("InsertProperty")

I think theres some thing wrong in the function but its saying the lowest line because it gets called there

Send the entire script please.

that is the intire script btw this one does work so its something with the gamepass

system = script.Parent

model = system.Box --

backup = model:Clone()

regen = system.Regen



function checkRegen()

	if regen.Value == 1 then

		wait(1)

		model = backup:Clone()

		model.Parent = system

		model:MakeJoints()

	end

end

regen.Changed:Connect(checkRegen)

Needs quotes afaik. “148181594”

LOL I SAID THAT IN MY HEAD

But yeah It could be Syntax tbf

3 Likes

but what is syntax I have no idea

I mean he fixed the OP Error, he actually defined the function when it wasn’t before, it’s just the AI forgtot define player in the function argument.

checkregen(plr)
function checkRegen(plr)
  --
end

Try This:

system = script.Parent

model = system.Box --

backup = model:Clone()

regen = system.Regen
game.Players.PlayerAdded:Connect(function(plr)
	
	local gamepassId = 148181594
	local market = game:GetService("MarketplaceService")
	
end)

function checkRegen()
	if regen.Value == 1 then
		if market:UserOwnsGamePassAsync(plr.UserId,gamepassId) then
			wait(1)
			model = backup:Clone()
			model.Parent = system
			model:MakeJoints()
		else
			market:PromptGamePassPurchase(plr, gamepassId)
		end
	end
end

regen.Changed:Connect(checkRegen)

the game doesnt know what market mean in the function because you called it in the playeradded event

1 Like

Are you purposely ignoring me…?

I’m sorry I gonna try that______

doesnt work either I have no ieda what the problem is

1 Like

Send a copy of the roblox world file please. Itll help solve it quicker