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

Mouse Tool Spawn on Click?

Asked by 9 years ago

So I made this script that a group of parts is copied from Lighting, and is moved to the position where the mouse is at that moment. I may have made it TOTALLY WRONG, and if so I'd like a wiki link (Or if you want to fix it that would be great too) as to how to fix it, or simple instructions. (See below the script for whats not working)

dum=game.Lighting.Dummy

plr=script.Parent.Parent.Parent

mouse=plr:GetMouse()

mouse.Button1Down:connect(function()

    h=mouse.Hit
    c=dum:Clone()
    c.Parent=game.Workspace

    nh=h+Vector3.new(0,5,0)

c:MoveTo(Vector3.new(nh))
end)

So far, it clones the dummy, and it appears on click. But it always teleports to the same spot no matter where I click. I assume I may have used Hit or Moveto incorrectly.

1 answer

Log in to vote
0
Answered by 9 years ago

You didn't use mouse.Hit correctly. Here is the corrected script: And make sure the dummy has a torso!

player = game.Players.LocalPlayer
mouse = player:GetMouse()

mouse.Button1Down:connect(function(m)
    local clone = game.Lighting.Dummy:Clone()
    clone.Parent = game.Workspace

    clone.Torso.CFrame = CFrame.new(mouse.Hit.p) + Vector3.new(0, 5, 0)
end)
0
Edited the final one. You're welcome :) Alucifer 45 — 9y
0
I feel so stupid haha, thanks. Tempestatem 884 — 9y
0
No problem :) Alucifer 45 — 9y
Ad

Answer this question