Money Printer model's script not working

  1. What do you want to achieve? Keep it simple and clear!

A money printer.

  1. What is the issue? Include screenshots / videos if possible!

ProximityPrompts not being triggered

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried switching from Triggered to TriggerEnded cause of hold duration, I tried to switch the hold duration from 2 to 0 and none of them worked. I tried to look for solutions, but didn’t find any.

local valuesfolder = script.Parent.Values



local maxcashval = 100000


local ownerval = valuesfolder.Owner


local cashval = valuesfolder.Cash


local Printing = valuesfolder.Printing


local waittime = valuesfolder.Time



local printedcash = valuesfolder.PrintedCash


local enabled = valuesfolder.Enabled



local soundsfolder = script.Parent.Sounds


local buttonsound = soundsfolder.Button



local printedsound = soundsfolder.Printed





local button = script.Parent.Button

local buttonpressed = script.Parent.ButtonPressed




local function onAnchestryChanged(child, parent)
	
	if parent.Name == "playerPlaced" then
		
		Printing.Value = true

		enabled.Value = false
		
	else
		
		Printing.Value = false
		
		enabled.Value = false
		
	end
	
end




script.Parent.AncestryChanged:Connect(onAnchestryChanged)



while task.wait(waittime.Value) and Printing.Value == true and enabled.Value == true do
	
	
	if cashval.Value < maxcashval then
		
		printedsound:Play()


		cashval.Value += printedcash.Value
		
		
	end
	
end




local function changecashtext(NewVal)
	
	script.Parent.Text.SurfaceGui.TextLabel.Text = "$".. NewVal
	
end


cashval.Changed:Connect(changecashtext)


local startstopproximity = script.Parent.Button.Prompt


startstopproximity.Triggered:Connect(function(plr)
	
	
	if plr.Character.Name == ownerval.Value and enabled.Value == false then
		
		
		buttonsound:Play()
		
		button.Transparency = 1
		
		
		buttonpressed.Transparency = 0
		
		task.wait(.5)
		
		button.Transparency = 0
		
		buttonpressed.Transparency = 1
		
		
		startstopproximity.ObjectText = "Stop"


		enabled.Value = true
		
		

	else
		if plr.Character.Name == ownerval.Value and enabled.Value == true then
			


			buttonsound:Play()

			button.Transparency = 1


			buttonpressed.Transparency = 0

			task.wait(.5)

			button.Transparency = 0

			buttonpressed.Transparency = 1
			
			
			startstopproximity.ObjectText = "Start"

			enabled.Value = false
			
			
			
		else
			
			if plr.Character.Name ~= ownerval.Value then
				
				return
				
			end
			
		end
		
		
		
	end
	
	
end)


local withdrawproximity = script.Parent.Text.ProximityPrompt


withdrawproximity.Triggered:Connect(function(plr)
	
	if plr.Character.Name == ownerval.Value then
		
		plr:WaitForChild("PlayerStats").Cash.Value += cashval.Value
		
		cashval.Value = 0
		
	end
	
end)

image

The money printer model is cloned and named player_moneyprinter then placed into the folder in workspace called “playerCreated”, from there only the player that placed it can interact with it.

The problem seems to be with the “withdrawproximity” ProximityPrompt, which is not being triggered when the player who is the owner of the money printer walks into the designated proximity. To debug the issue, you could try adding print statements around the “withdrawproximity.Triggered:Connect(function(plr))” block and see if the code inside is executing. You could also check if the “withdrawproximity” ProximityPrompt is working correctly, by testing it with other parts of your code.

One thing I found out is that I enable the “Enabled” value in a server script, then trigger the proximity it works (stops the printer) then you can start the printer