Trying to change a proximity prompts text when clicked

Hey there, ive been making a door any idea how do i change the text on it when its clicked
thanks!


3 Likes

I don’t see why this wouldn’t work

prompt.Triggered:Connect(function()
	prompt.ActionText = "New text!"
end)
1 Like

Thanks ill try that out now :smiley:

1 Like
local prompt; -- proximityprompt location
prompt.Triggered:Connect(function()
  prompt.ObjectText = "ping pong pingpong"
end)
1 Like

if i want to change it back to normal do i type the same thing?

1 Like
local prompt; -- proximityprompt location
local lastText = prompt.ObjectText
prompt.Triggered:Connect(function()
  prompt.ObjectText = lastText -- wont change anything because it is the last text
end)
1 Like

do i put all of that in a new script in the proximity prompt

1 Like

the door opening maybe…?


1 Like

alright ill try that now thank you

image got a error here

1 Like

put your prompt location


it doesn’t work still idk why :thinking:

I would help you, can you show the full code? Thank you!

sure let me get it

local Hinge = script.Parent.PrimaryPart
local opened = false

local Promt = script.Parent:WaitForChild("ProximityPrompt")

function OpenDoor()
    if opened == false then
        opened = true
        for i = 1, 21 do
            script.Parent:SetPrimaryPartCFrame(Hinge.CFrameCFrame.Angles(0, math.rad(5), 0))
            wait()
        end
    else
        opened = false
        for i = 1, 21 do
            script.Parent:SetPrimaryPartCFrame(Hinge.CFrameCFrame.Angles(0, math.rad(-5), 0))
            wait()
        end
    end
end
Promt.Triggered:Connect(function(Players)
    OpenDoor()
end)
script.Parent.Door.ProxomityPrompt.Triggered:Connect(OpenDoor)



local prompt = workspace.door4.ProximityPrompt -- proximityprompt location
local lastText = prompt.ObjectText
prompt.Triggered:Connect(function()
    prompt.ObjectText = lastText -- wont change anything because it is the last text
end)

prompt.Triggered:Connect(function()
    prompt.ActionText = "Close Door"
end)

Where do you get an error? I do not get an error.

yeah i dont get a error too it just doesnt change

Well, I just found your issue, you were triggering the prompt 2 times. Try this code.

local Hinge = script.Parent.PrimaryPart
local opened = false

local Promt = script.Parent:WaitForChild("ProximityPrompt")

function OpenDoor()
    if opened == false then
        opened = true
        for i = 1, 21 do
            script.Parent:SetPrimaryPartCFrame(Hinge.CFrameCFrame.Angles(0, math.rad(5), 0))
            wait()
        end
    else
        opened = false
        for i = 1, 21 do
            script.Parent:SetPrimaryPartCFrame(Hinge.CFrameCFrame.Angles(0, math.rad(-5), 0))
            wait()
        end
    end
end
Promt.Triggered:Connect(function(Players)
    OpenDoor()
end)
script.Parent.Door.ProxomityPrompt.Triggered:Connect(OpenDoor)



local prompt = workspace.door4.ProximityPrompt -- proximityprompt location
local lastText = prompt.ObjectText
local on = false
prompt.Triggered:Connect(function()
    on = not on
if on then
prompt.ObjectText = lastText
else
prompt.ActionText = "Close Door"
end
end)

prompt.Triggered:Connect(function()
    prompt.ActionText = "Close Door"
end)

Try this:

local Hinge = script.Parent.PrimaryPart
local opened = false
local toggle = false

local prompt = script.Parent:WaitForChild("ProximityPrompt")

function OpenDoor()
	if opened == false then
		opened = true
		for i = 1, 21 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrameCFrame.Angles(0, math.rad(5), 0))
			wait()
		end
	else
		opened = false
		for i = 1, 21 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrameCFrame.Angles(0, math.rad(-5), 0))
			wait()
		end
	end
end


prompt.Triggered:Connect(function(Players)
	OpenDoor()
end)
script.Parent.Door.ProximityPrompt.Triggered:Connect(OpenDoor)




local prompt = workspace.door4.ProximityPrompt -- proximityprompt location
local lastText = prompt.ObjectText
prompt.Triggered:Connect(function()
	toggle = not toggle
	
	if toggle == true then
		prompt.ActionText = "Close Door" 
	elseif toggle == false then
		prompt.ActionText = "Open Door"
	end
end)

Thank you ill try that out now

Oh wow, we almost typed the same code.