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)
model in workspace (after the “Starter” model’s parent changed to workspace)
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
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.