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

Why does Model not move to position of the mouse?

Asked by 7 years ago
Edited 7 years ago

Background: So I'm building a game like Clash of Clans, and I notice when I to :MoveTo(), it doesn't work. Beause I print the Vector3.new(mouse.Hit) it says 0, 0, 0.

Fail Solution: - I try doing :SetPrimaryPartCFrame(), it does weird "things". - I also try doing :TranslateBy(), it's an error.

local mouse = game.Players.LocalPlayer:GetMouse()
local ar = false


script.Parent.Equipped:Connect(function()
    print("TRUE")
    if ar ~= true then
        ar = true
        local f = Instance.new("Folder", workspace.PlayerBuilding)
        f.Name = game.Players.LocalPlayer.Name

        local w = game:GetService("Lighting").Level1Wall:Clone()
        w.Parent = f
    end
end)
script.Parent.Unequipped:Connect(function()
    print("TRUE")
    ar = false
    workspace.PlayerBuilding:FindFirstChild(game.Players.LocalPlayer.Name):Destroy()
end)

while wait(0.01) do
    if workspace.PlayerBuilding:FindFirstChild(game.Players.LocalPlayer.Name) then  
        local wa = workspace.PlayerBuilding:FindFirstChild(game.Players.LocalPlayer.Name).Level1Wall
        wa:MoveTo(Vector3.new(mouse.Hit))
    end
end

1 answer

Log in to vote
0
Answered by
Ziruken 139
7 years ago

At line 24, you have to add "mouse.Hit.p" instead of "mouse.Hit"

local wa = workspace.PlayerBuilding:FindFirstChild(game.Players.LocalPlayer.Name).Level1Wall

wa:MoveTo(Vector3.new(mouse.Hit.p))

Also check the Model API for more information on moving the Model

http://wiki.roblox.com/index.php?title=API:Class/Model

I hope I helped you!

0
Thank you for you answer! I will accept it once it work. MizeryGFX 15 — 7y
0
Alright, thanks. Ziruken 139 — 7y
0
Yeah it doesn't work MizeryGFX 15 — 7y
Ad

Answer this question