My goal here is to put the RayPart 5 units in front of the local characters HumanoidRootPart, relative to their orientation using CFrame:ToWorldSpace function, however, I get the error "attempt to index nil with 'HumanoidRootPart'" and I'm not really sure what it means. I think it means that nil is trying to read HumanoidRootPart, but that can't be, as the part does exist. The error is on line 11. LocalScript:
game.Loaded:Wait() -- To prevent loading issues
local player = game.Players.LocalPlayer
local char = player.Character
local rayPart = game.ReplicatedStorage.RayPart:Clone()
rayPart.Parent = workspace
game.ReplicatedStorage.GiveAbilityToTransfurm.OnClientEvent:Connect(function()
spawn(function()
while wait() do
rayPart.CFrame = char.HumanoidRootPart.CFrame:ToWorldSpace(CFrame.new(0, 0, 5))
end
end)
end)
I am not very experienced with CFrame, so this could be a very simple fix.

2 comments
All you have to do is define the character. The error was basically saying you're attempting to reference something that doesn't exist with a instance.
All you have to do is define the character. THE error was basically saying you're attempting to reference something that doesn't exist with a instance.