So basically my friend was coding a tool for a zombie spawner, it spawns the zombie from replicated storage to the mouse position, but it was not working
heres the local script (it activates a remote function which spawns the zombie)
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Event = script:FindFirstChildWhichIsA("RemoteEvent")
Mouse.Button1Down:Connect(function()
local Character = Player.Character
local ThisTool = Character:FindFirstChildWhichIsA("Tool")
if ThisTool ~= nil then
Event:FireServer(Mouse.hit)
end
end)
serverside script:
local RemoteEvent = script.Parent:FindFirstChildWhichIsA("RemoteEvent")
local RepSt = game.ReplicatedStorage
local Zombie = RepSt:FindFirstChild("Zombie")
RemoteEvent.OnServerEvent:Connect(function(mousehit)
print("work")
local ZombieMinion = Zombie:Clone()
local Root = ZombieMinion.PrimaryPart
Root.Position = Vector3.new(mousehit)
end)
it still has the “Attempt to index nil with ‘fireserver’,” the error is coming from the local script, not the server script, so it will not fire the server script because of the error
Event is nil because FindFirstChildWhichIsA is returning nil - the event is most likely replicated after the script checks for it. Try replacing FindFirstChildWhichIsA with WaitForChild.