Proximity Prompt in Module

Can you show the Initialize script? that is the only script that isn’t on here right?

this is the initialize script!

1 Like

i am sorry about that not sure how i over looked it! but anyway when you call v.Setup() should you be sending the door/item? i only have the one door and it works.

local modules = {}
local rep = game:GetService("ReplicatedStorage")
local serverModules = rep
local DOOR = workspace.Door
function Initialize()
	if serverModules then
		for _, v in pairs(serverModules:GetDescendants()) do
			if v:IsA('ModuleScript') and v.Name == "door" then
				local module = require(v)
				modules[v.Name] = module
			end
		end

		for i, v in pairs(modules) do
			if type(v.Setup) == 'function' then
				task.spawn(function()
					v.Setup(DOOR)
				end)
			end
		end
	else
		assert('not found lol; restart or do ur code better')
	end
end

Initialize()

sadly it didn’t work :frowning: and plus i updated the initialize code using bruh_specialists code. I tried implementing ur code but it didn’t work. I don’t know what the cause is because it doesn’t work on my module but i don’t want to copy and paste server scripts everywhere

This makes absolutely no sense here.

Where in your code do you go through the doors to put the prompt into?

this is basically it. I’m getting the descendants and checking for a attribute called Door

1 Like

I tried to find issues with proximity prompts, and i found that a lot of people are having issues with the prompts being parented to a model. Try and parent it to a basepart and see if that changes anything

1 Like

Do you have already a proximityPrompt inside for testing or? maybe check that out?

1 Like

So yes instead of having the door attribute in the model put it in the Main part of the door. It seems like troll said proximity prompts don’t like models.

OMG. it works now thank you so much!!!

But theres still something wrong. The proximity prompts runs 2 times. And also i tried tweening the door and it won’t move, i dunno why.

My code for the door(just the usedoor function, the setup function is the same as it was):

function module.UseDoor()
	for _, v in pairs(workspace:GetDescendants()) do
		if v and v:GetAttribute('Door') then
			local open = false
			local debounce = false
			
			local hinge = v:FindFirstChild('Hinge')
			local current = hinge.CFrame

			local goal: {}
			
			local info = TweenInfo.new(
				v:GetAttribute('Time'),
				Enum.EasingStyle[v:GetAttribute('TweenType')],
				Enum.EasingDirection.Out
			)

			if not debounce then
				debounce = true
				if not open then
					open = true
					openDoorSound:Play()		
					openDoorSound.Stopped:Connect(function()
						for _, v in pairs(v:GetChildren()) do
							if v:IsA('BasePart') then
								v.CanCollide = false
							end
							goal = {CFrame = current * CFrame.Angles(0, math.rad(90), 0)}
						end
					end)
				else
					open = false
					closeDoorSound:Play()		
					closeDoorSound.Stopped:Connect(function()
						for _, v in pairs(v:GetChildren()) do
							if v:IsA('BasePart') then
								v.CanCollide = true
							end
							goal = {CFrame = current * CFrame.Angles(0, math.rad(0), 0)}
						end
					end)
				end
			end
			
			local tween = TS:Create(hinge, info, {goal})
			tween:Play()
			tween.Completed:Wait()
			
			task.wait(0.2)
			
			debounce = false
		end
	end
end

Do you already have a proxy prompt in the doors main part? I see there’s something in it ?

i added it via the setup function so i thought i didn’t need to change it.
It’s the same code but just changed the parent.

local properties = {
	ActionText = 'Use Door',
	MaxActivationDistance = 7,
	RequiresLineOfSight = false
}
			
objectModule.CreatePrompt(v:FindFirstChild('Main'), module.UseDoor, properties)

What’s the problem now? Also can you send the script again. I will try in my edit.

Like Dlbsp1983 is saying, do you still have the door attribute on the model? Because that might be whats causing the code to run twice per door (assuming you changed the basepart to have the attribute aswell)

Also, about the tweening not happening, try and change this:
local tween = TS:Create(hinge, info, {goal})
to this:
local tween = TS:Create(hinge, info, goal)

1 Like

Assuming you removed the Door attribute from the model, this code wouldn’t work anymore anyway. You need to update your for loops

for _, v in pairs(v:GetChildren()) do
							if v:IsA('BasePart') then
								v.CanCollide = true
							end
							goal = {CFrame = current * CFrame.Angles(0, math.rad(0), 0)}
						end

as they’re still iterating thru children in v that are BaseParts (assuming your door hierarchy is still the same as it was in an above post)

1 Like

i want to keep the Door attribute so i can make anything a door

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