Attempt to index local Clone (a nil value)

Server script

game.ReplicatedStorage.KnifeThrow3.OnServerEvent:Connect(function(Player, CF, X, Y, Z, ToPos, Start)
	local RS = game:GetService("ReplicatedStorage")
	local ClientTouch = RS:WaitForChild("ClientTouch")
	local Knife = RS:WaitForChild("Knife")
	local Stepped
	
	local Clone = Knife:Clone()
	
	ClientTouch:FireClient(Player, Clone)
	Clone.Parent = workspace
	Clone.CFrame = CF
	Clone.Anchored = false
	local BodyF = Instance.new("BodyForce")
	BodyF.Parent = Clone
	BodyF.Force = Vector3.new(0, Clone:GetMass() * game.Workspace.Gravity, 0)
	Clone.Velocity = Vector3.new(X*200, Y*200, Z*200)
	Clone:SetNetworkOwner(Player)
	
	--local UpVec = Vector3.new(0, 1, 0)
	--local Cross = UpVec:Cross(Vector3.new(Clone.Velocity.X, Clone.Velocity.Y, Clone.Velocity.Z))
	--Clone.RotVelocity = Cross
end)

Local script

local RS = game:GetService("ReplicatedStorage")
local ClientTouch = RS:WaitForChild("ClientTouch")

ClientTouch.OnClientEvent:Connect(function(Player, Clone)
	Clone.Touched:Connect(function(Hit)
		print("yes")
	end)
end)

help i don’t know whats wrong

2 Likes

OnClientEvent does not pass the Player who was :FireClient’d because the Client already knows who its self is. The problem is occurring because you’re actually setting the part passed to the variable Player

Instead do this, OnClientEvent:Connect(function(Clone)

1 Like

I tried that it still doesn’t work

What is that script for exactly…?

I just want to detect hits faster so I try using it in local script

1 Like

Well, try this. https://www.roblox.com/library/4778573939/MetallicThrowingKnives the throwing script is fast.

nvm i was thought that u were trying to access replicatedstorage from client

OnClientEvent doesn’t have a player parameter, so just delete that, and only have clone as a parameter.

still does not work im not sure why tbh

Is the error happening in the server script, or the local script?

I dont think you can send instances with RemoteEvents

1 Like

it is happening in the local script

After removing the Player parameter, what is the script now?

local RS = game:GetService("ReplicatedStorage")
local ClientTouch = RS:WaitForChild("ClientTouch")

ClientTouch.OnClientEvent:Connect(function(Clone)
	Clone.Touched:Connect(function(Hit)
		print("yes")
	end)
end)

What if you were to try firing the RemoteEvent after the properties of the clone have been set?