Hi, I’m trying to get a remote function from an ancestor, but it says the parent is workspace?? I don’t understand and I have searched everywhere
script.Parent.Parent.Parent.Parent.Summon.OnServerEvent:Connect(function(player)
local char = player.Character
local humrp = char:FindFirstChild("HumanoidRootPart")
while wait() do
script.Parent.CFrame = humrp.CFrame * CFrame.Angles(-8,0,0)
end
end)
This is probably because Summon hasn’t loaded in yet, use Instance:WaitForChild() to stop the script from running until it loads, like this:
local summmon = script.Parent.Parent.Parent.Parent:WaitForChild("Summon")
summon.OnServerEvent:Connect(function(player)
local char = player.Character
local humrp = char:FindFirstChild("HumanoidRootPart")
while wait() do
script.Parent.CFrame = humrp.CFrame * CFrame.Angles(-8,0,0)
end
end)
Tools work by replicating themselves from StarterPack into the player’s Backpack upon joining, and then to the player’s character in the workspace when equipped. Your script is trying to reference the event in the player’s Backpack instead of the event in the tool parented to the player’s character.
Instead, it’s good practice to store your RemoteEvents in ReplicatedStorage, where they’re accessible to both the client and server, and connecting them in a LocalScript in your tool like this:
local RS : ReplicatedStorage = game:GetService("ReplicatedStorage")
local event : RemoteEvent = RS:WaitForChild("RemoteEvent")
event:FireServer(args)
Type in the text below:
local summon = script.Parent.Parent.Parent.Parent:WaitForChild(“Summon”)
When you get to the part WaitForChild(" the word Summon should appear when you type an S.
Does the word “Summon” auto-fill for you? If not, then the path is wrong. Try changing the number of Parents you have until the word autofills as expected.
When it throws that error, it means Roblox thinks it will never find Summon, so that means its an error more than what I thought. I would play the game and look at your inventory in-game to make sure all the paths work, like @anon_j1124 said.