Problem with filling system with prompt / Not resolved

Hello, I make a system that filling watering can. The normal duration is 20 seconds. But I have a problem. Help me.

If you see, at the end, i need to press multiple time to finish filling. It’s not normal…

Here is the script for the filling :

local prompt = script.Parent.ProximityPrompt

local CanFill = true

prompt.PromptButtonHoldBegan:Connect(function(plr)
	local char = plr.Character
	local WateringTool = plr.Backpack:FindFirstChild("WateringCan") or char:FindFirstChild("WateringCan")

	prompt.HoldDuration = WateringTool.Duration.Value

	if WateringTool.Fill.Value < 100 and CanFill == true then
		CanFill = false
		repeat wait()
			WateringTool.Fill.Value += 1
			WateringTool.Duration.Value -= 0.2
			wait(0.2)
			if WateringTool.Fill.Value >= 100 then
				break
			end
			print(WateringTool.Duration.Value)
		until CanFill == true
	end
end)

prompt.PromptButtonHoldEnded:Connect(function(plr)
	CanFill = true
	local char = plr.Character
	local WateringTool = plr.Backpack:FindFirstChild("WateringCan") or char:FindFirstChild("WateringCan")
	prompt.HoldDuration = WateringTool.Duration.Value
	print("STOP")
end)

havent really looked that deep into the code but i dont think you are resetting the hold duration value after filling, why are you even changing the hold duration value in the first place?

Because, if the player don’t want to fill the entire of the watering can, the prompt holding duration will change. For exemple : I fill 1/2 of my watering can, if I i want to fill the rest, the prompt will have 1/2 of the base time which is 20 seconds

you can award him by each second of the prompt trigger being active instead of reducing the hold duration and break when the prompt is no longer being used

I don’t understand (sorry), Can you explain me what I should do ?

Try this and let me know, i just modified it a little also use task.wait() instead of wait() because wait() will yield the whole script where as task.wait() wont yield

Is there a little problem, it work but i need to click on prompt a second time because my watering can is not full

can you record and send? its hard to understand

i modified the above script a little, can you try once again? with the new script i mean

It’s like in the vidéo : ( I don’t know…

hmmmm, is it showing 88 like in the video or some other value?

No, this time it’s showing 95 (30 letters)

try doing it a couple of times and if it says 95 all the times, increase the prompt duration by a little

It work ! Thank you ! (30 letters)

1 Like

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