Errors occuring when I attempt to change proximity prompt text

I can record a video of the gameplay and the error log when I get home from school later today, that’s if you don’t forget lol

1 Like

That’s the script that I found on youtube and which is working

local ProximityPromptService = game:GetService("ProximityPromptService")
local TweenService = game:GetService("TweenService")

ProximityPromptService.PromptShown:Connect(function(promptInstance: ProximityPrompt)
	if promptInstance.Style == Enum.ProximityPromptStyle.Default then return end
	local CustomProximity = game.ReplicatedStorage:WaitForChild("Assets"):WaitForChild("ProximityPrompt"):Clone()
	CustomProximity:WaitForChild("CustomProximity").ObjectText.Text = promptInstance.ObjectText
	CustomProximity:WaitForChild("CustomProximity"):WaitForChild("ActionText").Text = promptInstance.ActionText
	CustomProximity:WaitForChild("CustomProximity"):WaitForChild("KeyboardKeyCode").Text = promptInstance.KeyboardKeyCode.Name
	promptInstance.PromptHidden:Once(function()
		if CustomProximity then
			CustomProximity:Destroy()
		end
	end)
	
	local progressbar = CustomProximity:WaitForChild("CustomProximity"):WaitForChild("ProgressBar"):WaitForChild("ProgressBar")
	local tweninfo = TweenInfo.new(
		promptInstance.HoldDuration
	)
	local Tween = TweenService:Create(progressbar, tweninfo, {Size = UDim2.fromScale(1, 1)})
	promptInstance.PromptButtonHoldBegan:Connect(function()
		if not progressbar.Visible then
			progressbar.Visible = true
		end
		Tween:Play()
	end)
	promptInstance.PromptButtonHoldEnded:Connect(function()
		Tween:Cancel()
		progressbar.Size = UDim2.fromScale(0, 1)
	end)
	CustomProximity.Parent = promptInstance.Parent
end)

I don’t think you need tween part (Its just so you can see progress of proximity)
image
image

Forgot to say that it’s a client script located in replicated first

Not sure what you are doing totally here…
Went with changing the properties in the new prompt to match the text labels.
Prompt in ReplicatedStorage is Default style
Prompt in workspace.part is Custom style

Maybe
local replicatedstorage = game:GetService("ReplicatedStorage")
local proximitypromptservice = game:GetService("ProximityPromptService")
local tweenservice = game:GetService("TweenService")
local player = game.Players.LocalPlayer

local function PressedTween (prompt)
	local pressedtweengoal = {}
	pressedtweengoal.Size = UDim2.new(0.20, 0, 0.65, 0)
	pressedtweengoal.BackgroundColor3 = Color3.new(0.694118, 0.694118, 0.694118)
	local pressedtweeninfo = TweenInfo.new(
		.1,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out,
		0,
		false
	)
	local PressedTween = tweenservice:Create(prompt.Parent:FindFirstChild("PromptUI").InputText, pressedtweeninfo, pressedtweengoal)
	PressedTween:Play()
end

local function ReleasedTween (prompt)
	if prompt.Parent:FindFirstChild("PromptUI") then
		local ReleasedTweengoal = {}
		ReleasedTweengoal.Size = UDim2.new(0.25, 0, 0.7, 0)
		ReleasedTweengoal.BackgroundColor3 = Color3.new(1, 1, 1)
		local ReleasedTweenInfo = TweenInfo.new(
			.1,
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.Out,
			0,
			false
		)

		local ReleasedTween = tweenservice:Create(prompt.Parent:FindFirstChild("PromptUI").InputText, ReleasedTweenInfo, ReleasedTweengoal)
		ReleasedTween:Play()
	end

end


proximitypromptservice.PromptShown:Connect(function(prompt)
	if prompt.Style == Enum.ProximityPromptStyle.Default then
		return
	end

	if prompt.Parent:FindFirstChild("PromptUI")~=nil then return
	end	

	local custompromptui = replicatedstorage.PromptUI:Clone()
	custompromptui.Parent = prompt.Parent

	custompromptui.ObjectText=custompromptui:WaitForChild("ObjectText").Text
	custompromptui.ActionText=custompromptui:WaitForChild("ActionText").Text
	custompromptui.KeyboardKeyCode=custompromptui:WaitForChild("InputText").Text
end)

proximitypromptservice.PromptHidden:Connect(function(prompt)
	if prompt.Style == Enum.ProximityPromptStyle.Default then
		return
	end
	local custompromptui = prompt.Parent.PromptUI
	custompromptui:Remove()
end)

proximitypromptservice.PromptTriggered:Connect(function(prompt)
	PressedTween(prompt)
	wait(0.1)
	ReleasedTween(prompt)
end)

proximitypromptservice.PromptButtonHoldBegan:Connect(function(prompt)
	PressedTween(prompt)
end)

proximitypromptservice.PromptButtonHoldEnded:Connect(function(prompt)
	ReleasedTween(prompt)
end)

My mistake, you do want to modify the object text. I modify the object and action text all time via server in my game, so I was confused about the issue. The only clue I see is that the error is being produced on the BillboardGui and not the Proximity Prompt object itself? I see a lot of post after mine but not sure if the issue has been resolved yet?

The prompt in replicated storage is a billboard gui and doesn’t have that custom or default value

just tried this as soon as i got home, thank you so much! turns out thats all i needed.

1 Like

happy to hear that :smile: this is my first time solving a problem on this platform

2 Likes

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