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)
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)
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?
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)