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

Moving a model with mouse?

Asked by
k1nq 30
8 years ago
local P = game.Players.LocalPlayer
local Plr = P.Character or P.CharacterAdded:wait()
local H = Plr:WaitForChild("Humanoid")
local Mouse = P:GetMouse()
local model = Instance.new("Model")
model.Name = "Test"
model.Parent = game.Workspace.Camera


for i,v in pairs(game.lighting.Test:GetChildren()) do
    v:Clone().Parent = game.Workspace.CurrentCamera.Test
end
local new = game.Workspace.CurrentCamera.Test:GetChildren()
local part = game.Lighting.Test.Part
wait(1)

game["Run Service"].RenderStepped:connect(function()
    if Mouse.target then
        new.CFrame = CFrame.new(math.floor(Mouse.hit.p.X),math.floor(Mouse.hit.p.Y),math.floor(Mouse.hit.p.Z))
    end
end)

Mouse.Button1Down:connect(function()
    if script.Value.Value == 0 then
        local ya = Instance.new("Model",game.Workspace)
        ya.Name = "Test"
        for i,v in pairs(game.Workspace.CurrentCamera.Test:GetChildren()) do
            v:Clone().Parent = game.Workspace.Test
            v.Transparency = 0
        for i, v in pairs(game.Workspace.CurrentCamera.Test:GetChildren()) do
            v:Remove()
        script.Value.Value = 1
        end
        end
    end
end)

So, currently I have this but the model won't seem to show up.

Any ideas on how to fix it?

1
The best way to move a model is by setting primary part, and then PrimaryPartCFrame, as the entire model will keep the same orientation as the primary part moves Xoqex 75 — 8y
0
So what would the code look like then, I've never used PrimaryPartCFrame k1nq 30 — 8y

Answer this question