Trying to change a proximity prompts text when clicked

nope there are no errors :thinking:

image
image
door doesnt open

How did it open before if the code didnā€™t work :thinking:

well, what i needed was the prompts to say close door when it was open and open door when it was closed

The code you sent before was broken and didnā€™t work so perhaps you messed it up while posting it?

the door script worked fine before

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.CFrame*CFrame.Angles(0, math.rad(5), 0))
			wait()
		end
	else
		opened = false
		for i = 1, 21 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-5), 0))
			wait()
		end
	end
end
Promt.Triggered:Connect(function(Players)
	OpenDoor()
end)
script.Parent.Door.ProxomityPrompt.Triggered:Connect(OpenDoor)

Thatā€™s kinda awfully slow for a opening animation, are you aware that Radians go from where the Unit Circle startsā€¦?

local Hinge = script.Parent.PrimaryPart
local opened = false
local RunService = game:GetService("RunService")

local prompt = script.Parent.ProximityPrompt

function OpenDoor()
	if opened == false then
		opened = true
		prompt.ActionText = "Close Door" 
		for i = 0, 75, 1 do
			Hinge.CFrame = Hinge.CFrame*CFrame.Angles(0, math.rad(i), 0)
			RunService.Heartbeat:Wait()
		end
		
	elseif opened == true then
		opened = false
		prompt.ActionText = "Open Door"
		for i = 75, 0, -1 do
			Hinge.CFrame = Hinge.CFrame*CFrame.Angles(0, math.rad(i), 0)
			RunService.Heartbeat:Wait()
		end	
	end
end
1 Like

shall i just put the old script to open the door in there?

You could first try my script and see if anything changes at all, I think I did mess something up with the CFrames however

that doesnt seem to work too :thinking:

Could you try adding some random print("Hello this is a test") statements in the script to see what outputs back?

If Jackscarlettā€™s script doesnā€™t work you can try using this one. In theory it should work :thinking:

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

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

local RunService = game:GetService("RunService")

function OpenDoor()
	if opened == false then
		opened = true
		for i = 1, 21 do
			Hinge.CFrame = Hinge.CFrame*CFrame.Angles(math.rad(5), 0, 0)
			RunService.Heartbeat:Wait()
		end
		Promt.ActionText = "Close Door"
		script.Parent.Door.ProximityPrompt.Action = "Close Door"
	else
		opened = false
		for i = 1, 21 do
			Hinge.CFrame = Hinge.CFrame*CFrame.Angles(math.rad(-5), 0, 0)
			RunService.Heartbeat:Wait()
		end
		Promt.ActionText = "Open Door"
		script.Parent.Door.ProximityPrompt.Action = "Open Door"
	end
end
Promt.Triggered:Connect(function(Players)
	OpenDoor()
end)
script.Parent.Door.ProximityPrompt.Triggered:Connect(OpenDoor)

image
it does this now

Is that the hinge? if so make sure to weld it to the actual door. If both of those donā€™t work then try this:

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

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

local RunService = game:GetService("RunService")

function OpenDoor()
	if opened == false then
		opened = true
		for i = 1, 21 do
			Hinge.CFrame = Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0)
			RunService.Heartbeat:Wait()
		end
		Promt.ActionText = "Close Door"
		script.Parent.Door.ProxomityPrompt.Action = "Close Door"
	else
		opened = false
		for i = 1, 21 do
			Hinge.CFrame = Hinge.CFrame*CFrame.Angles(0, math.rad(-5), 0)
			RunService.Heartbeat:Wait()
		end
		Promt.ActionText = "Open Door"
		script.Parent.Door.ProxomityPrompt.Action = "Open Door"
	end
end
Promt.Triggered:Connect(function(Players)
	OpenDoor()
end)
script.Parent.Door.ProxomityPrompt.Triggered:Connect(OpenDoor)

image

Did you type the name of the door correctly? and set its location correctly?

Iā€™ve made a door like this before, I just make a separate proximity prompt that gets enabled once the first proximity prompt is triggered. I know itā€™s not a very clean solution, but it does get the job somewhat done.

thats smart and probably easier to do can you possibly send the code for that?

Iā€™ve made an entire game out of that, here is some basic code:

Made in forum

First script:

script.Parent.TriggerEnded:Connect(function()
    script.Parent.Parent.Parent.Parent.Door.Transparency = 1
    script.Parent.Parent.Parent.Parent.Door.CanCollide = false
    script.Parent.Parent.Parent.Attachment2.ProximityPrompt.Enabled = true
    script.Parent.Enabled = false
end)

Second script:

script.Parent.TriggerEnded:Connect(function()
    script.Parent.Parent.Parent.Parent.Door.Transparency = 0
    script.Parent.Parent.Parent.Parent.Door.CanCollide = true
    script.Parent.Parent.Parent.Attachment1.ProximityPrompt.Enabled = true
    script.Parent.Enabled = false
end)

Just swap that out for the door opening, I would personally make a door opening animation and make that play using an animation controller, and when the animation begins, make the door cancollide false, then make when it is done, angle the door to look open and then make it cancollide true.