Hi, I’m a novice developer developing a horror game. I ran across this issue where it errors on the subject of ancestry when the things are set up correctly, This is the error:
The explorer:
Hi, I’m a novice developer developing a horror game. I ran across this issue where it errors on the subject of ancestry when the things are set up correctly, This is the error:
The explorer:
Can we see the script called onKeyClicked?
Sure:
--under StarterPlayerScripts:
local player = game.Players.LocalPlayer
local key = game.Workspace.clickedTool.Click
key.ClickDetector.MouseClick:Connect(function()
if player.Backpack:FindFirstChild("clickedTool") then else
key.Parent = player.Backpack
end
end)
Try this
--under StarterPlayerScripts:
local player = game.Players.LocalPlayer
local key = game.Workspace.clickedTool:WaitForChild("Click")
key.ClickDetector.MouseClick:Connect(function()
if player.Backpack:FindFirstChild("clickedTool") then else
key.Parent = player.Backpack
end
end)
Are there multiple instances called clickedTool?
No there’s only one, I couldn’t find anything else using the search filter tool.
Can you show everything else in the tool?
From whatever script your accessing the tool, can you print the children of clickedTool?
How about trying:
--under StarterPlayerScripts:
local player = game.Players.LocalPlayer
local key = game.Workspace:WaitForChild("clickedTool"):WaitForChild("Click"); if not key then print("No key found or key is never initialized.") end
key.ClickDetector.MouseClick:Connect(function()
if not player.Backpack:FindFirstChild("clickedTool") then
key.Parent = player.Backpack
end
end)
Since this is in StarterPlayerScript, the tool could be on a non-replicated state.
That just means that clickedTool is nowhere found in the workspace. How is the clickedTool placed in the workspace? Is it with :Clone() or is it already just there?
It’s not a cloned tool, and I thought I’d parented it into the workspace last time checked with search filter tool?
you thought? where is it located at?
No I’m just saying, if it’s not found by the script then I guess studio doesn’t recognise it in the workspace then
That’s my only assumption… if I’m not wrong
Start the game and look where clickedTool is with the search filter
I did and it was in the workspace - there would be no other place for it to be parented under if it was in the workspace this whole time
There’s also no other scripts interrupting with the ancestry of it - that’s the only one.