Parenting is wrong

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

image

image

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)
1 Like

The path to Summon looks correct. But I’m not sure you can use a remote event like that.

Try:

local summon = script.Parent.Parent.Parent.Parent:WaitForChild("Summon")

summon.OnServerEvent:Connect(function(player)
-- script
end)
2 Likes

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)
1 Like

I’m assuming the tool is in StarterPack.

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)

Hope this helps.

1 Like

its coming up with this:
image

trying this now

character limit

1 Like

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.

1 Like

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.

1 Like

it auto fills, but then gives the infinite yield error

Is your tool in the workspace or backpack when you test?

its in the backpack

char limit

Can you send a screenshot of what your backpack looks like when in-game?

i deleted the remote event because i tried @anon_j1124’s method, but it was under local

I see whats wrong. Summon isn’t moving to your backpack. I’d put all RemoteEvents in ReplicatedStorage, and change the paths in the scripts.

yea i did that

character limit

Now all you have to do is fire the RemoteEvent from your tool’s LocalScript, like I mentioned before.

1 Like

Are you sure that the error is coming from the script you think it is?

yes its coming from the server script

just tried that and it works like a charm. thanks to everyone who helped

1 Like