Hit is not a valid member of CFrame

  1. What do you want to achieve? I want to make so the part will throw the position of where the mouse clicked

  2. What is the issue? It is saying " Hit is not a valid member of CFrame"

  3. What solutions have you tried so far? I tried to use vector3 and CFrame.new and I tried to find any solutions in the hub

Script

local tool = script.Parent
local char = tool.Parent
local handle = script.Parent.Handle
local remote = game.ReplicatedStorage.Lol
local TweenService = game:GetService("TweenService")
local active = script.Parent.Activated1.Value
local eqq = script.Parent.Eqquiped1.Value
local kam = game.Workspace.Kam


remote.OnServerEvent:Connect(function(player, Mouse)
	
	tool.Equipped:Connect(function()

		print("Weqq")
		
		local players = game:GetService("Players")
		
		eqq = true

		local clone = kam:Clone()
		clone.Parent = game.Workspace
		clone.Anchored = true
		clone.CanCollide = false
		clone.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,5,0)
		
		wait(1.5)
		
		local tweenInfo = TweenInfo.new(
			2, -- Time
			Enum.EasingStyle.Linear, -- EasingStyle
			Enum.EasingDirection.Out, -- EasingDirection
			-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
			true, -- Reverses (tween will reverse once reaching it's goal)
			0 -- DelayTime
		)
		
		local Goal = {}
		Goal.Orientation = clone.Orientation + Vector3.new(0,7200,0)
		
		local Tween = TweenService:Create(clone, tweenInfo, Goal)
		Tween:Play()
		
		
		tool.Activated:Connect(function()
			if eqq == true then
				
				local BodyVelocity = Instance.new("BodyVelocity")
				BodyVelocity.Parent = clone
				BodyVelocity.Velocity = Mouse.Hit.lookVector * 110
				BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

			end
		end)
		
		

	end)
	
	tool.Unequipped:Connect(function()
		
		eqq = false
		
	end)
	
end)

Local script

local tool = script.Parent
local char = tool.Parent
local handle = script.Parent:WaitForChild("Handle")
local player = game.Players.LocalPlayer
local remote = game.ReplicatedStorage.Lol
local mouse = player:GetMouse()

tool.Equipped:Connect(function()

	
	remote:FireServer(mouse.Hit)
	

end)

Tool properties
Screenshot_45

Error in output
Screenshot_46

Any ideas on how would I fix that problem?

you are passing mouse.Hit
then doing .Hit on the mouse.Hit which doesnt work

so use Mouse.lookVector instead

1 Like

Mouse.Hit returns a cframe, so you’re essentially doing:

Cframe.Cframe = etc.

It is saying “Hit is not a valid member of Vector3”
I add lookVector as you said remote:FireServer(mouse.Hit.lookVector)

use remote:FireServer(mouse) cause you are sending it to the server but on the server you are doing .Hit so if you pass the .Hit you are doing .Hit twice which causes the error so either change the server to not use .Hit or change the client to not send the .Hit

also idk if you can just send the mouse to the server so try this if it doesnt work:
remote:FireServer({["Hit"]=mouse.Hit})

It is saying attempt to index nil with 'Hit'


I didn’t bother reading the script sorry, your firing mouse over to the server, Mouse doesn’t replicate and can’t be accessed via server even through a remote event (I think) instead you can do:

Remote:FireServer(Mouse.Hit)

and in the server:

Bv.Velocity = Mousehit.lookVector * 110

attempt to index nil with 'lookVector'

attempt to index nil with 'lookVector'

try firing mouse.hit.lookvector*110 instead

Wait! I DIDN’T FIRE THE tool.activated sorry for caps

You did not do it right cause it should have worked… Ill just add it to your full scripts for you

server

local tool = script.Parent
local char = tool.Parent
local handle = script.Parent.Handle
local remote = game.ReplicatedStorage.Lol
local TweenService = game:GetService("TweenService")
local active = script.Parent.Activated1.Value
local eqq = script.Parent.Eqquiped1.Value
local kam = game.Workspace.Kam


remote.OnServerEvent:Connect(function(player, MouseHit)
	tool.Equipped:Connect(function()
		print("Weqq")
		local players = game:GetService("Players")
		eqq = true
		local clone = kam:Clone()
		clone.Parent = game.Workspace
		clone.Anchored = true
		clone.CanCollide = false
		clone.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,5,0)
		wait(1.5)
		local tweenInfo = TweenInfo.new(
			2, -- Time
			Enum.EasingStyle.Linear, -- EasingStyle
			Enum.EasingDirection.Out, -- EasingDirection
			-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
			true, -- Reverses (tween will reverse once reaching it's goal)
			0 -- DelayTime
		)
		local Goal = {}
		Goal.Orientation = clone.Orientation + Vector3.new(0,7200,0)
		local Tween = TweenService:Create(clone, tweenInfo, Goal)
		Tween:Play()
		tool.Activated:Connect(function()
			if eqq == true then
				local BodyVelocity = Instance.new("BodyVelocity")
				BodyVelocity.Parent = clone
				BodyVelocity.Velocity = MouseHit.lookVector * 110
				BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

			end
		end)
	end)
	tool.Unequipped:Connect(function()
		eqq = false
	end)
end)

local

local tool = script.Parent
local char = tool.Parent
local handle = script.Parent:WaitForChild("Handle")
local player = game.Players.LocalPlayer
local remote = game.ReplicatedStorage:WaitForChild("Lol")
local mouse = player:GetMouse()


tool.Equipped:Connect(function()
	remote:FireServer(mouse.Hit)
end)

Ok now there is no errors but it is not throwing so. I will try to fire the tool.Activated

I can say that you almost solved it but it is not throwing, sorry if I’m bothering to you now.

ServerScript

local Equipped = false
local Character = nil
local Player = nil
script.Parent.Equipped:Connect(function()
	Character = script.Parent.Parent
	Player = game.Players:GetPlayerFromCharacter(Character)
	Equipped = true
end)
script.Parent.Unequipped:Connect(function()
	Character = nil
	Player = nil
	Equipped = false
end)


local MousePos = Instance.new("RemoteFunction")
MousePos.Name = "MousePos"
MousePos.Parent = script.Parent


local Projectile = Instance.new("Part")
Projectile.Name = "Projectile"
Projectile.Size = Vector3.new(1, 1, 1)
Projectile.Material = Enum.Material.Neon
Projectile.Color = Color3.fromRGB(255, 0, 0)


script.Parent.Activated:Connect(function()
	local MouseHit = MousePos:InvokeClient(Player)
	local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
	if HumanoidRootPart then
		local Clone = Projectile:Clone()
		Clone.CFrame = HumanoidRootPart.CFrame * CFrame.new(0, 5, 0)
		Clone.Parent = workspace
		local BodyVelocity = Instance.new("BodyVelocity")
		BodyVelocity.Velocity = MouseHit.lookVector * 110
		BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		BodyVelocity.Parent = Clone
		game:GetService("Debris"):AddItem(Clone, 5)
		Clone.Touched:Connect(function(hit)
			if hit.Parent == Character then return end
			local Humanoid = hit.Parent:FindFirstChild("Humanoid")
			if Humanoid then
				Humanoid:TakeDamage(25)
			end
		end)
	end
end)

Localscript

local MousePos = script.Parent:WaitForChild("MousePos")
local Mouse = game.Players.LocalPlayer:GetMouse()
MousePos.OnClientInvoke = function()
	return Mouse.Hit
end

ProjectileTool.rbxl (22.8 KB)

It’s not the same script but you can modify it to add whatever your old script was trying to do

1 Like

Yes, now it is working! Thank you so much