Proximity Prompt Customizing Help

Hello, I was triying to make a custom Proximity Prompt system when I wanted to make a bar wich shows your progress (the number of sec you need to keep holding until the proximity prompt gets trigged).
This is my code:

local players = game:GetService("Players")
local player = players.LocalPlayer
local ProxS = game:GetService("ProximityPromptService")
local ProxModel = script:WaitForChild("Prox")
local TweenS = game:GetService("TweenService")
local TweenI03 = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

local function GetGui()
	local Gui = player.PlayerGui:FindFirstChild("ProximityPrompts")
	if not Gui then
		Gui = Instance.new("ScreenGui")
		Gui.Name = "ProximityPrompts"
		Gui.Parent = player.PlayerGui
	end
	return Gui
end

ProxS.PromptShown:Connect(function(Prompt, InputType)
	Prompt.Style = Enum.ProximityPromptStyle.Custom
	local ProxGui = ProxModel:Clone()
	local ProgressBar = ProxGui.Background.Progress.Loaded
	ProxGui.Parent = GetGui()
	ProxGui.Background.ActionText.Text = Prompt.ActionText
	ProxGui.Background.ObjectText.Text = Prompt.ObjectText
	ProxGui.Background.Press.Text = Prompt.KeyboardKeyCode.Name
	ProxGui.Adornee = Prompt.Parent
	ProxGui.Background.Size = UDim2.fromScale(1,0)
	local IsCliking = false
	local ClickedE = ProxGui.Background.Press.MouseButton1Click:Connect(function()
		if not IsCliking then
			IsCliking = true
			Prompt:InputHoldBegin()
            --Put here smt
			ProxGui.Background.Press.MouseButton1Click:Wait()
			Prompt:InputHoldEnd()
		end		
	end)
	local Tween = TweenS:Create(ProxGui.Background, TweenI03, {Size = UDim2.fromScale(1,1)})
	Tween:Play()
	Prompt.PromptHidden:Wait()
	Tween:Destroy()
	local Tween = TweenS:Create(ProxGui.Background, TweenI03, {Size = UDim2.fromScale(1,0)})
	Tween:Play()
	Tween.Completed:Wait()
	Tween:Destroy()
	ProxGui:Destroy()
	ClickedE:Disconnect()
end)

I want the bar declared as “ProgressBar” in the third line of the function have the size of the sec the player has holded/Duration Time, something like this: Udim2.fromScale(Prompt.DurationTime/Prompt.CurrentHoldingTime, 1)
Any Idea?

Ok, Update:
I made this

local players = game:GetService("Players")
local player = players.LocalPlayer
local ProxS = game:GetService("ProximityPromptService")
local ProxModel = script:WaitForChild("Prox")
local TweenS = game:GetService("TweenService")
local TweenI03 = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

local function GetGui()
	local Gui = player.PlayerGui:FindFirstChild("ProximityPrompts")
	if not Gui then
		Gui = Instance.new("ScreenGui")
		Gui.Name = "ProximityPrompts"
		Gui.Parent = player.PlayerGui
	end
	return Gui
end

ProxS.PromptShown:Connect(function(Prompt, InputType)
	Prompt.Style = Enum.ProximityPromptStyle.Custom
	local ProxGui = ProxModel:Clone()
	local ProgressBar = ProxGui.Background.Progress.Loaded
	ProxGui.Parent = GetGui()
	ProxGui.Background.ActionText.Text = Prompt.ActionText
	ProxGui.Background.ObjectText.Text = Prompt.ObjectText
	ProxGui.Background.Press.Text = Prompt.KeyboardKeyCode.Name
	ProxGui.Adornee = Prompt.Parent
	ProxGui.Background.Size = UDim2.fromScale(1,0)
	local IsCliking = false
	local ClickedE = ProxGui.Background.Press.MouseButton1Click:Connect(function()
		if not IsCliking then
			IsCliking = true
			Prompt:InputHoldBegin()
			ProxGui.Background.Press.MouseButton1Click:Wait()
			Prompt:InputHoldEnd()
		end		
	end)
	local ProgressBarTween = TweenS:Create(ProgressBar, TweenInfo.new(Prompt.HoldDuration, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Size = UDim2.fromScale(1,1)})
	local PromptButtonBegan = Prompt.PromptButtonHoldBegan:Connect(function(player)
		ProgressBarTween:Play()
	end)
	local PromptButtonEnded = Prompt.PromptButtonHoldEnded:Connect(function()
		ProgressBarTween:Pause()
	end)
	local Tween = TweenS:Create(ProxGui.Background, TweenI03, {Size = UDim2.fromScale(1,1)})
	Tween:Play()
	Prompt.PromptHidden:Wait()
	Tween:Destroy()
	local Tween = TweenS:Create(ProxGui.Background, TweenI03, {Size = UDim2.fromScale(1,0)})
	Tween:Play()
	Tween.Completed:Wait()
	Tween:Destroy()
	ProgressBarTween:Destroy()
	ProxGui:Destroy()
	ClickedE:Disconnect()
	PromptButtonBegan:Disconnect()
	PromptButtonEnded:Disconnect()
end)

And if the player don’t stop holding the Prompt, all will be good the problem is that when the player releases it, it goes not inmediatly to 0. In what time do it come back? (To be able to do the same with the bar.)

I finally made it to go instantatly to 0. Is not the best but it works kind of good.

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