Proximity prompt won't work after being in replicated storage and put into the workspace

basically I want the proximity prompt to work when the model gets put into the games workspace.

the model in the replicated storage (before the “Starter” model’s parent changes)

proximity prompt in replicated storage

model in workspace (after the “Starter” model’s parent changed to workspace)

Capture

The script:

local enabled = false

print("enabled")

game.ReplicatedStorage.Models.Starter.Starter.Parent.Changed:Connect(function()
	
	print("part")
	
	if game.ReplicatedStorage.Models.Starter.Starter.Parent == game.Workspace then
		
		print("part2")
		enabled = true
	end
end)

while enabled == true do
	local prox = script.Parent

	local model = script.Parent.Parent.Parent

	local key = model:WaitForChild("Key")

	print("key1")

	prox.Triggered:Connect(function(player)
		print("triggered")
		if player then
			print(player)
			key.Parent = player.Backpack
			model.Trigger:Destroy()
		end

	end)

	key.Parent.Changed:Connect(function()
		prox:Destroy()
	end)
end

Try using :GetPropertyChangedSignal(“Parent”) instead.

local enabled = false

print("enabled")

game.ReplicatedStorage.Models.Starter.Starter:GetPropertyChangedSignal("Parent"):Connect(function()
	
	print("part")
	
	if game.ReplicatedStorage.Models.Starter.Starter.Parent == game.Workspace then
		
		print("part2")
		enabled = true
	end
end)

while enabled == true do
	local prox = script.Parent

	local model = script.Parent.Parent.Parent

	local key = model:WaitForChild("Key")

	print("key1")

	prox.Triggered:Connect(function(player)
		print("triggered")
		if player then
			print(player)
			key.Parent = player.Backpack
			model.Trigger:Destroy()
		end

	end)

	key.Parent.Changed:Connect(function()
		prox:Destroy()
	end)
end
1 Like

That’s what I was gonna to say when you’re using Changes on the parent it’s detecting change for the parent not the child’s parent changing.

1 Like

Also, on line 9, you’re checking what game.ReplicatedStorage.Models.Starter.Starter.Parent is after it’s already been changed. Assign Starter to a variable and then check what Starter’s parent is.