How to know if proximity is triggered

what i want: if i clicked 100 proximity prompt will show and once you press e the border will be destroyed (ik i have to add debounce because autoclickers exist ill add it in later)

script:

local Players = game:GetService("Players")
local client = Players.LocalPlayer
client.PlayerGui.ScreenGui.TextButton.MouseButton1Click:Connect(function(hit)


	local prop = game.Workspace.Part.ProximityPrompt
	prop.Parent =  game.Workspace.Part
	prop.Enabled = false
	local playerPoints = client.leaderstats.gold  
	playerPoints.Value = playerPoints.Value + 1 

	if playerPoints.Value >= 100 then 
		prop.Enabled = true 

		if prop.Triggered == true then
			prop.Parent:Destroy() 
		end

	end   
end) 

the main area im having problems with is here:

if prop.Triggered == true then
			prop.Parent:Destroy() 
		end

also local script is in a textbutton in startergui
and proximity prompt in a part

1 Like

So, basically what you did is, that when the game started, the triggered will play one time, so add a while wait(1) do loop

1 Like

ok
(30char ant is hot bro a b cn)

Well if prop.Triggered == true then is not how it works.
please read these events ProximityPrompt

The .Triggered is an function the example will be shown below:

script.Parent.Triggered:Connect(function()
print(“Test”)
end)

1 Like

OHHHHHHHHHHHHHHHHHHHHHHHHHH i now got it brain go boom boom xd

1 Like
script.Parent.Triggered:Connect(function()
print("Hello World")

Outside of the function all you need to do is the following.

prop.Triggered:Connect(function(player)
	--do stuff here
end)

Somewhere after “prop” has been declared.

local Players = game:GetService("Players")
local client = Players.LocalPlayer
local prop = game.Workspace.Part.ProximityPrompt

prop.Triggered:Connect(function(player)
	--here
end)

client.PlayerGui.ScreenGui.TextButton.MouseButton1Click:Connect(function(hit)


	prop.Parent =  game.Workspace.Part
	prop.Enabled = false
	local playerPoints = client.leaderstats.gold  
	playerPoints.Value = playerPoints.Value + 1 

	if playerPoints.Value >= 100 then 
		prop.Enabled = true 

		if prop.Triggered == true then
			prop.Parent:Destroy() 
		end

	end   
end) 

Also the “MouseButton1Click” event isn’t passed any argument so the received parameter named “hit” can be removed as it doesn’t represent any value (is nil).

1 Like