Script Problem, Proximity Prompt - Return

Hello! I have tried several options to make this work but the problem persists, how do I solve this?

As soon as I don’t have enough money and open the prompt it neatly displays that code, only when I have enough money to do it again it doesn’t work anymore. How do I solve this?

Thank you in advance! Below is a piece of code from my script.

I don’t get any errors in the console for this either. ^


script.Parent.Parent.PayPart.Attachment.ProximityPrompt.Triggered:Connect(function(plr)

	if plr.leaderstats.Money.Value >= 1000 then
	
		plr.leaderstats.Money.Value = plr.leaderstats.Money.Value  -MyModule.COSTS
		
	else 
		if plr.leaderstats.Money.Value <= 1000 then 
			script.Parent.Parent.PayPart.Attachment.ProximityPrompt.ActionText = "YOU DON'T HAVE ENOUGH MONEY"
			wait(5)
			script.Parent.Parent.PayPart.Attachment.ProximityPrompt.ActionText = "PAY"
			return
		end
		end
end)
3 Likes

are you adding the money on the server side?

1 Like

Yes, it is, but I now know what the problem is, it is due to the piece of return in the last code, only after that it no longer works. If it has been performed 1 time. From there I have no idea how to solve it further or use any other way.

what is the mymodule.costs? try using mymodule.costs.value and also remove the return if there’s no code below

That’s the problem, there’s another piece of code underneath that makes something work. the module only shows the amount that is debited each time, the payment continues to work, but if you have insufficient money and then enough again, it no longer works.

There is no need for a return there unless you have something underneath, it will stop the function there and then. And why are you using <= and >=? What if someone has exactly 1000?

The return is there because there is code underneath it. The >= does not matter much because it is a standard amount, it is more so that it does not fall below 0.

Make sure your proximity prompt works and the function runs, remove the return and also make sure you’re editing the right values and the path is right, change the wait to task.wait, other than that if its still not solved just drop the full script and mabye i will figure it out

Thank you! I’ve just tried it, it works now. Thank you for the assistance.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.