'CFrame is not a valid member of Player' even though there was no mention of Player

  1. What do you want to achieve?
    I would like a model/NPC (name of Looter) to spawn near the player when the remote event is fired

  2. What is the issue?
    This keeps popping up in the Output even though I didn’t transfer the parameter of Player

  3. What solutions have you tried so far?
    I changed it into HumanoidRootPart, Head and other parts of the character

-- Localscript
local looterevent = game.ReplicatedStorage.LooterEvent
local button = script.Parent
local gui = script.Parent.Parent.Parent
local quest = game.ReplicatedStorage.chosenquest
local questlist = game.Players.LocalPlayer.PlayerGui.ScreenGui.ScrollingFrame
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()



button.MouseButton1Click:Connect(function()
local root = char:WaitForChild("Torso")
	gui:Destroy()
	local Q1 = quest:Clone()
	Q1.Parent = questlist
	looterevent:FireServer(root)
end)
--------------------------------
-- Server script
local looterevent = game.ReplicatedStorage.LooterEvent
local looter = game.ReplicatedStorage.looter

looterevent.onServerEvent:Connect(function(root)

	local newlooter = looter:Clone()
	newlooter.Parent = workspace
	newlooter.PrimaryPart.CFrame = root.CFrame * CFrame.new(0,0,-5)

	end)


The first parameter of the .OnServerEvent function is always the player that sent it

4 Likes

Adding on to @CodedE44OR’s answer:

Try using this:

looterevent.onServerEvent:Connect(function(player, root)
2 Likes