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

Zombies not move to Mouse Position. Can some one help?

Asked by 3 years ago
Edited 3 years ago

I dont know why my zombies always move to one point no matter where I click can someone help`~~


local rp = game:GetService("ReplicatedStorage") local remote = rp:FindFirstChild("Z1") remote.OnServerEvent:Connect(function(player, val, Mouse) if val == "CommandZombie" then for i,v in pairs(workspace:GetChildren()) do if v.Zombie then v.Zombie:MoveTo(Vector3.new(Mouse)) end end end end)
0
Explain your parameters SoftlockedUnderZero 668 — 3y
0
I posted my local script below. It is clearer thinhs11 -2 — 3y

2 answers

Log in to vote
0
Answered by
Ghost40Z 118
3 years ago

You forgot to do Mouse.lookVector

local rp = game:GetService("ReplicatedStorage")
local remote = rp:FindFirstChild("Z1")
remote.OnServerEvent:Connect(function(player, val, Mouse)
    if val == "CommandZombie" then
        for i,v in pairs(workspace:GetChildren()) do
            if  v.Zombie then
                v.Zombie:MoveTo(Vector3.new(Mouse.lookVector))

            end        

        end
    end
end)
0
let me try itt thinhs11 -2 — 3y
0
error : lookVector is not a valid member of Vector3 thinhs11 -2 — 3y
0
error : lookVector is not a valid member of Vector3 thinhs11 -2 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

this is my local script

local rp = game:GetService("ReplicatedStorage")
local remote = rp:FindFirstChild("Z1")
local tool =  script.Parent


tool.Activated:Connect(function()

            local player = game.Players.LocalPlayer
            local mouse = player:GetMouse()
            local  Mouse = mouse.Hit.Position   

            --debounce here

                remote:FireServer("CommandZombie", Mouse)

                --debounce here

end)


0
Mouse.Hit Returns CFrame so basically if you wanna use Mouse.Hit the only way you're getting away with it is basically just teleporting the zombie. kepiblop 124 — 3y
0
yea,u right. I change to Moveto and it works now thinhs11 -2 — 3y
0
Using lookvector will make it walk towards well i haven't tested it but using mouse.Hit.LookVector will make it walk towards somewhere to your mouse. kepiblop 124 — 3y

Answer this question