Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why my zombies keep spawning at the same place?

Asked by 3 years ago
local tool = script.Parent
local RunService = game:GetService("RunService")




    local function onActivated()
    local zombie = game.ReplicatedStorage.Zombie
        local human = tool.Parent.Humanoid
        local mouse = game.Players.LocalPlayer:GetMouse()

    local e = Instance.new("Explosion")
    e.DestroyJointRadiusPercent = 10  
    e.Position = mouse.Hit.Position
    e.Parent = workspace

    local part = Instance.new("Part", workspace)
    part.Position = mouse.Hit.Position

    local clone = zombie:clone()
    clone.Parent = workspace
    local chaclone = clone:WaitForChild("Character") 
    if chaclone.HumanoidRootPart then
        clone.HumanoiRootPart.Position = part.Position
    end



    end

    tool.Activated:Connect(onActivated)

1 answer

Log in to vote
0
Answered by
TGazza 1336 Moderation Voter
3 years ago

try this:

local tool = script.Parent
local RunService = game:GetService("RunService")




    local function onActivated()
    local zombie = game.ReplicatedStorage.Zombie
        local human = tool.Parent.Humanoid
        local mouse = game.Players.LocalPlayer:GetMouse()

    local e = Instance.new("Explosion")
    e.DestroyJointRadiusPercent = 10  
    e.Position = mouse.Hit.Position
    e.Parent = workspace

   --[[
 this but isnt really needed unless you're creating something other than your zombie at the mouse.Hit.position
 local part = Instance.new("Part", workspace)
    part.Position = mouse.Hit.Position
]]
    local clone = zombie:clone()
    clone.Parent = workspace

    local chaclone = clone:WaitForChild("Character") 
    if chaclone.HumanoidRootPart then 

        clone:MoveTo(mouse.Hit.Position) 
        -- clone.HumanoiRootPart.Position = part.Position
    end



   -- end <<-- this needed?!

    tool.Activated:Connect(onActivated)

just swapped out moving its HumanoidRootPart with the inbuilt Model:MoveTo(Vector3)

Hope this helps! :)

0
So if they spawn in the same place make more spawns and put more of the thing you want on the spawn chase_chasas 0 — 3y
Ad

Answer this question