Remote Event Error returning nil

Server:

local RemoteEvent = script.Parent:WaitForChild("LocalToServer")
local tool = script.Parent
local Missle = game:GetService("ServerStorage"):FindFirstChild("Missle")
local AliveMissles = 0

local speed = 0.25
local WaitTime = 0
local ClonedMissle

RemoteEvent.OnServerEvent:Connect(function(player)
	AliveMissles = AliveMissles + 1
	local UsingNuke = true
	ClonedMissle = Missle:Clone()
	ClonedMissle.Parent = workspace:WaitForChild("Missles")
	ClonedMissle.Position = player.Character:WaitForChild("HumanoidRootPart").Position + Vector3.new(0,10,0)
	ClonedMissle.Name = "Missle"..tostring(AliveMissles)
	
	tool.ServerToLocal:FireClient(player,AliveMissles)
	
	while UsingNuke do
		game.Workspace.Missles["Missle"..tostring(AliveMissles)].CFrame = ClonedMissle.CFrame + ClonedMissle.CFrame.LookVector * speed
		task.wait(WaitTime)
	end
end)

Local:

local RemoteEvent = script.Parent:WaitForChild("LocalToServer")
local tool = script.Parent
local Player = game.Players.LocalPlayer

tool.Activated:Connect(function()
	RemoteEvent:FireServer(Player)
end)

tool.ServerToLocal.OnClientEvent:Connect(function(plr,AliveMissles)
	local missle = game.Workspace:WaitForChild("Missles")["Missle"..tostring(AliveMissles)]
	local character = Player.Character
	game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
	game:GetService("RunService").Stepped:Connect(function()
		if missle then
			game.Workspace.CurrentCamera.CFrame = missle.CFrame + Vector3.new(0, 10, 5)
		end
	end)
end)

RemoteEvents names: LocalToServer and ServerT local

What I need help with: Self Explanatory but I will give a bit more info

I have been working on this for a bit and it just won’t work with anything I try.

Thanks in advance!

2 Likes

ServerToLocal *

`

:smirk: :smirk: :yum:2024-01-16T13:00:00Z

`

Remove “Player” from this :FireServer

and remove “plr” from this function

On the client you dont have to send or receive your localplayer since it happens automatically, this should fix this

1 Like

^^^ What he said.

Documentation can be found here: