Proximityprompt triggers another script, even though it doesnt have a script in it

so basically, i was making a game. then i wanted to insert proximityprompts. so literally what i did was make a door script and it worked etc. but when i inserted another part and added a proximity part, with no script in it. it triggered the door script. this is the door script.

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

local TS = game:GetService("TweenService")

local door = workspace.leftdoor.Door

local button = script.Parent.Parent.Parent

local moving = workspace.Doorer.Mover

local moving2 = workspace.Righdoor.Door

-- Detect when prompt is triggered

local function onPromptTriggered(promptObject, player)

script.Parent:Destroy()

TS:Create(door, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(125.623, 22.308, 16.574)}) :Play()

TS:Create(moving, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(134.273, 14.893, 17.12)}) :Play()

TS:Create(moving2, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(118.201, 13.874, 23.365)}) :Play()

player:WaitForChild("PlayerGui").Subtitles.Speaking.Text = "This is broken."

player:WaitForChild("PlayerGui").Subtitles.Namer.Text = "You:"

wait(2)

player:WaitForChild("PlayerGui").Subtitles.Speaking.Text = "Oh well, there is no going back now i guess."

player:WaitForChild("PlayerGui").Subtitles.Namer.Text = "You:"

wait(2)

player:WaitForChild("PlayerGui").Subtitles.Speaking.Text = " "

player:WaitForChild("PlayerGui").Subtitles.Namer.Text = " "

end

-- Detect when prompt hold begins

local function onPromptHoldBegan(promptObject, player)

TS:Create(door, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(125.623, 22.308, 16.574)}) :Play()

TS:Create(moving, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(134.273, 14.893, 17.12)}) :Play()

TS:Create(moving2, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(118.201, 13.874, 23.365)}) :Play()

end

-- Detect when prompt hold ends

local function onPromptHoldEnded(promptObject, player)

TS:Create(door, TweenInfo.new(1,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out),{Position = Vector3.new(125.623, 14.058, 16.574)}) :Play()

TS:Create(moving, TweenInfo.new(1,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out),{Position = Vector3.new(133.423, 14.893, 17.12)}) :Play()

TS:Create(moving2, TweenInfo.new(5,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out),{Position = Vector3.new(118.201, 21.814, 23.365)}) :Play()

end

-- Connect prompt events to handling functions

ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)

ProximityPromptService.PromptButtonHoldBegan:Connect(onPromptHoldBegan)

ProximityPromptService.PromptButtonHoldEnded:Connect(onPromptHoldEnded)

soo yeah, its really annoying. can anyone help?

Can we see the hierarchy of how the door model looks like with the script in it?

what do you mean exactly? sorry, my english is very bad.

Show us how the model looks like in the explorer tab.

the prxoimity that triggers the door
image
the door that needs to open
image

Show me everything inside leftdoor.

image

How do you exactly place the script in the leftdoor model?

there is no script in leftdoor. the script in LeftDoorButton moves it.

leftdoor is defined as one your variables, are you sure you haven’t referenced it? You have a lot of variables going on, so you should double check that you haven’t referenced your other door.

Also, you need to clarify what the issue exactly is. It’s quite vague right now. Is the issue that your left door is moving?

I think I recommend you to create a new script for the toggle of leftdoor.

1 Like

as i said in the post, any proximityprompt with 0 scripts in it triggers the door

I believe that’s because you are using the proximity prompt service which causes the script to act globally on each proximity prompt triggered where you should be using proximity prompt object instead to make it specific to that door instead.

So according to your hierarchy in the model, you should do this by connecting the events to the proximity prompt object instead.

local doorProximityPrompt = script.Parent

doorProximityPrompt.PromptTriggered:Connect(onPromptTriggered)

doorProximityPrompt.PromptButtonHoldBegan:Connect(onPromptHoldBegan)

doorProximityPrompt.PromptButtonHoldEnded:Connect(onPromptHoldEnded)

that, doesn’t work. and also, not every proximityprompt in the game triggers the door.

that, is a pretty vague statement. What doesn’t work? What did you do? Nothing pops up? Any error message? Anything to help us work from?

Anyway here is the full script which includes reference to the door proximity prompt Instance, I still believe the issue is caused by using proximity prompt service instead of the Instance. Also, do you have multiple scripts copied and pasted that use proximity prompt services that might be the issue as well?

BTW, this uses .Triggered instead of .PromptTriggered since the Instance doesn’t have that event as seen within the documentation sorry about that, that may be the error.

--reference the proximity prompt Instance and not the service
local doorProximityPrompt = script.Parent

local TS = game:GetService("TweenService")

local door = workspace.leftdoor.Door

local button = script.Parent.Parent.Parent

local moving = workspace.Doorer.Mover

local moving2 = workspace.Righdoor.Door

-- Detect when prompt is triggered

local function onPromptTriggered(promptObject, player)

script.Parent:Destroy()

TS:Create(door, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(125.623, 22.308, 16.574)}) :Play()

TS:Create(moving, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(134.273, 14.893, 17.12)}) :Play()

TS:Create(moving2, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(118.201, 13.874, 23.365)}) :Play()

player:WaitForChild("PlayerGui").Subtitles.Speaking.Text = "This is broken."

player:WaitForChild("PlayerGui").Subtitles.Namer.Text = "You:"

wait(2)

player:WaitForChild("PlayerGui").Subtitles.Speaking.Text = "Oh well, there is no going back now i guess."

player:WaitForChild("PlayerGui").Subtitles.Namer.Text = "You:"

wait(2)

player:WaitForChild("PlayerGui").Subtitles.Speaking.Text = " "

player:WaitForChild("PlayerGui").Subtitles.Namer.Text = " "

end

-- Detect when prompt hold begins

local function onPromptHoldBegan(promptObject, player)

TS:Create(door, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(125.623, 22.308, 16.574)}) :Play()

TS:Create(moving, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(134.273, 14.893, 17.12)}) :Play()

TS:Create(moving2, TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Position = Vector3.new(118.201, 13.874, 23.365)}) :Play()

end

-- Detect when prompt hold ends

local function onPromptHoldEnded(promptObject, player)

TS:Create(door, TweenInfo.new(1,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out),{Position = Vector3.new(125.623, 14.058, 16.574)}) :Play()

TS:Create(moving, TweenInfo.new(1,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out),{Position = Vector3.new(133.423, 14.893, 17.12)}) :Play()

TS:Create(moving2, TweenInfo.new(5,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out),{Position = Vector3.new(118.201, 21.814, 23.365)}) :Play()

end

-- Connect prompt events to handling functions

doorProximityPrompt.Triggered:Connect(onPromptTriggered)

doorProximityPrompt.PromptButtonHoldBegan:Connect(onPromptHoldBegan)

doorProximityPrompt.PromptButtonHoldEnded:Connect(onPromptHoldEnded)

first of all, sorry.

basically i made a door with proximity prompt, but other proximity prompts triggers it too.

no. not a single error.

i just wanted to see what i was doing wrong

and about the script, that worked, thank you.

1 Like