I have a script that moves the player to a specific part when a ProximityPrompt is triggered. One of the ProximityPrompts functions, but the other does not. This issue occurs only with the server script, whereas in a local script, both ProximityPrompts work. When I try printing, one doesn’t work while the other works fine. here is the server script:
-- this one works --
script.Parent.Enter.ProximityPrompt.Triggered:Connect(function(plr)
plr.Character.HumanoidRootPart.Position = script.Parent.Start.Position + Vector3.new(0,2,0)
if script.Parent.Reset.Value == true then
script.Parent.Reset.Value = false
else
script.Parent.Reset.Value = true
end
end)
-- this one dose not --
script.Parent.Door.ProximityPrompt.Triggered:Connect(function(plr)
print(plr.Name)
plr.Character.HumanoidRootPart.Position = script.Parent.Exit.Position + Vector3.new(0,2,0)
end)
Is the door already there when the game starts? in the local script you used waitforchild, maybe you can try using it in server script, If this doesnt work please give more context about the issue
Are “Enter” and “Door” close to eachother? If so, are the “Enter” and “Door” prompts assigned to the same keybind? Because if yes, one will take precedence over the other
-- this one works --
script.Parent:WaitForChild("Enter").ProximityPrompt.Triggered:Connect(function(plr)
plr.Character.HumanoidRootPart.Position = script.Parent.Start.Position + Vector3.new(0,2,0)
if script.Parent.Reset.Value == true then
script.Parent.Reset.Value = false
else
script.Parent.Reset.Value = true
end
end)
-- this one dose not --
script.Parent:WaitForChild("Door").ProximityPrompt.Triggered:Connect(function(plr)
print(plr.Name)
plr.Character.HumanoidRootPart.Position = script.Parent.Exit.Position + Vector3.new(0,2,0)
end)
script.Parent.Reset.Changed:Connect(function()
for _, part in ipairs(script.Parent["Current Rooms"]:GetChildren()) do
part:Destroy()
end
for _, part in ipairs(script.Parent.Checks:GetChildren()) do
part:Destroy()
end
script.Parent.Rooms.Value = 0
local hall = game.ReplicatedStorage.Dungeon.Hallway:Clone()
hall:SetPrimaryPartCFrame(script.Parent.Start.CFrame)
hall.Parent = game.Workspace["New Dungeon"]["Current Rooms"]
script.Parent.Rooms.Value += 1
end)
I’m not creating them through a script; I’ve simply placed them there. I’ve shown everything about those two prompts there is. However, I believe I could generate the prompts through scripts and configure them.
-- this one dose not --
print(script.Parent:WaitForChild("Door").Name) -- checking if Door is found to see if triggered can connect.
script.Parent:WaitForChild("Door").ProximityPrompt.Triggered:Connect(function(plr)
Its found. Also I just tried to run it in a new script that contains only this:
-- this one dose not --
script.Parent:WaitForChild("Door").ProximityPrompt.Triggered:Connect(function(plr)
print(plr.Name)
plr.Character.HumanoidRootPart.Position = script.Parent.Exit.Position + Vector3.new(0,2,0)
end)