CFrame isn't a valid member of player, although the player is never affected

I’m trying to make it so that when you click on something it has a shake effect, similar to the Undertale death effect shake. But whenever you click on it, I get an error that says, “Target is not a valid member of Player “Players.PixelCrix””

LocalScript:

local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local remoteEvent = tool:WaitForChild("RemoteEvent")

local ore

local level = tool:WaitForChild("Level").Value
local speed = tool:WaitForChild("Speed").Value

db = false

local outOfReachColor = Color3.new(1, 0, 0)
local inReachColor = Color3.new(0, 1, 0)

tool.Activated:Connect(function()
	if mouse.Target ~= nil and mouse.Target.Name == "Ore" and db == false then
		
		db = true
		
		local charPos = player.Character.HumanoidRootPart.Position
		local targetPos = mouse.Target.Position
		local magnitude = (charPos - targetPos).magnitude
		
		local outLine = Instance.new("Highlight")
		outLine.FillTransparency = 0.75
		outLine.Parent = mouse.Target
		outLine.Adornee = mouse.Target
		outLine.DepthMode = Enum.HighlightDepthMode.Occluded
		
		if magnitude > 10 then
			outLine.FillColor = outOfReachColor
			outLine.OutlineColor = outOfReachColor
		elseif magnitude <= 10 and level >= mouse.Target:WaitForChild("Level").Value then
			ore = mouse.Target
			outLine.FillColor = inReachColor
			outLine.OutlineColor = inReachColor
			remoteEvent:FireServer(player, ore)
		end
		
		if level < mouse.Target.Level.Value then
			outLine.FillColor = outOfReachColor
			outLine.OutlineColor = outOfReachColor
		end
		
		task.wait(speed)
		outLine:Destroy()
		db = false
		ore = nil
	end
end)

ServerScript:

local tool = script.Parent
local remoteEvent = tool:WaitForChild("RemoteEvent")

local speed = tool:WaitForChild("Speed").Value
local damage = tool:WaitForChild("Damage").Value
local multiplier = tool:WaitForChild("Multiplier").Value

remoteEvent.OnServerEvent:Connect(function(player, ore)
	
	local setPoint = ore.CFrame
	ore.CFrame += Vector3.new(math.random(-3,3),0,math.random(-3,3))
	task.wait(speed/4)
	ore.CFrame += Vector3.new(math.random(-3,3),0,math.random(-3,3))
	task.wait(speed/4)
	ore.CFrame += Vector3.new(math.random(-3,3),0,math.random(-3,3))
	task.wait(speed/4)
	ore.CFrame = setPoint
	
	if ore.Health.Value == 0 then
		ore:Destroy()
	else
		ore.Health.Value -= damage
	end
end)

Can you mark which line causes the error?

1 Like

local setPoint = ore.CFrame in ServerScript causes the error

Don’t send the player as an argument. Roblox does that automatically.

remoteEvent:FireServer(ore)
2 Likes