Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My zombie keep spawing at the same place?

I use the UserInputService to get E is the key when I press zombie will spawn on my cursor. I don't know what is wrong with my script


local zombie = game.ServerStorage:WaitForChild("Zombie")

game.ReplicatedStorage.Zombie.OnServerEvent:Connect(function(player)

	local mouse = player:GetMouse()
	local character = workspace:WaitForChild(player.Name)

	wait()
	local a = Instance.new("Animation", character)
	a.AnimationId = "rbxassetid://5713765649"

	local a1 =  character:WaitForChild("Humanoid"):LoadAnimation(a)
	a1:Play()

	while true do
		local character = player.Character
		local newZombie = zombie:Clone()
		newZombie.Parent = game.Workspace
		newZombie.CFrame = mouse.Hit
		
	end
	wait(1)
	

	
			end)	




	wait(2)


4 comments

0

It also say ServerScriptService.Zombiee:19: attempt to index nil with 'Hit'

0

did you try using mouse.Hit.CFrame?

0

it didnt work. It still says ServerScriptService.Zombiee:19: attempt to index nil with 'Hit'

0

you have not set cframe of the zombie

2 answers

I tried something that I get mouse through client script, but the zombie still does not spawn on mouse hit. I don't have any error either

local zombie = game.ServerStorage:WaitForChild("Zombie")
	 
	game.ReplicatedStorage.Zombie.OnServerEvent:Connect(function(player,firePosition)
		 
	local mouse = player:GetMouse()

		    local character = workspace:WaitForChild(player.Name)
	 
		    wait()
		    local a = Instance.new("Animation", character)
		    a.AnimationId = "rbxassetid://5713765649"
		 
		    local a1 =  character:WaitForChild("Humanoid"):LoadAnimation(a)
		    a1:Play()
	local Player = game:GetService("Players").LocalPlayer
	local character = player.Character
	local newZombie = zombie:Clone()

	if tostring(newZombie) == tostring(firePosition) then
		newZombie.Parent = game.Workspace
		newZombie.CFrame = firePosition 

		
	end
			    	      			
		    wait(1)
		 			 
		            end)   
 
	 
	    wait(2)



100% Fixed

local zombie = game.ServerStorage:WaitForChild("Zombie")

    game.ReplicatedStorage.Zombie.OnServerEvent:Connect(function(player,firePosition)

    local mouse = player:GetMouse()

            local character = workspace:WaitForChild(player.Name)

            wait()
            local a = Instance.new("Animation", character)
            a.AnimationId = "rbxassetid://5713765649"

            local a1 =  character:WaitForChild("Humanoid"):LoadAnimation(a)
            a1:Play()
    local Player = game:GetService("Players").LocalPlayer
    local character = player.Character
    local newZombie = zombie:Clone()

    if tostring(newZombie) == tostring(firePosition) then
        newZombie.Parent = game.Workspace
        newZombie.Position = mouse.Hit.p 


    end

            wait(1)

                    end)   


        wait(2)

1 comment

0

nothing happens bro,@@ idk what's wrong

This discussion is preserved as it was. New answers, comments, and votes are closed.