How to make part move after proximity prompt is used so many times

I am making a game, and I need some help. I’ve searched youtube for a tutorial but it doesn’t really have what I need.

What I have

What I have
https://gyazo.com/49cddb73859dd8390dd6c403e24f1e92

What I want

After punching so many times, the rock would get moved/teleported.

you can do this. Add a server script inside the proximity prompt

local Prompt = script.Parent
local TimesTriggered = 0 -- how many time it's been triggered
local TimesNeeded = 5 -- how many times the prompt needs to be triggered
Prompt.Triggered:Connect(function(Player)
	if TimesTriggered >= TimesNeeded then
		print(string.format("the prompt was triggered %.f times.", TimesTriggered)) -- remove this if you want. 
        --- do stuff
	end
	TimesTriggered+= 1
end)

@rollystone55

Thank you! It works, now I just need to make it so it goes to a random position after the TimesNeeded is exceeded. Any idea of how to do it?

I think you should mark my post as solution since it works and make another topic about it. Or google search on how to get a random position.

You could try something like this: (Updated code)

local Prompt = script.Parent
local TimesTriggered = 0 -- how many time it's been triggered
local TimesNeeded = 5 -- how many times the prompt needs to be triggered
Prompt.Triggered:Connect(function(Player)
if TimesTriggered >= TimesNeeded then
print(string.format("the prompt was triggered %.f times.", TimesTriggered)) -- remove this if you want. 
local cloneRock = Prompt.Parent:Clone()
cloneRock.Parent = workspace
cloneRock.Position = Vector3.new(math.random(-50,50), 0, math.random(-50,50))

Prompt.Parent:Destroy()
end
TimesTriggered+= 1
end)

I just got it to work as you responded! Thank you for the help!

no problem! glad I could help you out!

There is however one problem. After it gets moved once, it only takes one trigger to move it again. Is there a way to sort of restart the TimesTriggered after the TimesNeeded is exceeded?

yeah really simple

local Prompt = script.Parent
local TimesTriggered = 0 -- how many time it's been triggered
local TimesNeeded = 5 -- how many times the prompt needs to be triggered
Prompt.Triggered:Connect(function(Player)
	if TimesTriggered >= TimesNeeded then
		print(string.format("the prompt was triggered %.f times.", TimesTriggered)) -- remove this if you want. 
        --- do stuff
--- AFTER you do the stuff add this
TimesTriggered = 0
	end
if not TimesTriggered >= TimesNeeded  then
	TimesTriggered+= 1
end
end)

Ohh awesome! When I tried I did it in the wrong way. Thank you so much!

no problem. if you have any more questions then just shoot me a DM. Because any time you reply to this topic, it’ll bump it to the top.

Use the format option %d or %i for integer values.

Didn’t know that. Thx for the extra info.