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

How do I make a mouse.Target moving system?

Asked by 9 years ago

Basically I'm trying to create a system where you click the part named "part" and then it clones to your mouse e.g mouse position - and then you can place it onto a certain block and then detach it from your mouse.

No errors in output whatsoever I just need help with figuring this out - thanks! - If you can help and not down-vote because of some horrid reason.

It works and function via HopperBin not a tool - but if you want to help and re-script it to work with a normal tool, you can.

Entirely your choice.

Basically I just want to make it where you click a "part" like a patty and then you can place it firmly onto a grill - that's an example description.

Here's the code so far:

local sp = script.Parent

local players = game:GetService("Players")
local player = players.LocalPlayer

local part = script:WaitForChild("part")
part.Parent = game:GetService("Workspace").CurrentCamera

sp.Selected:connect(function(mouse)

mouse.TargetFilter = part

mouse.Move:connect(function()

if mouse.Hit ~= nil then

part.Transparency = .5

part.Position = mouse.Hit.p
part.Rotation = Vector3.new(0, 0, 0)

end 
    end)

mouse.Button1Down:connect(function()

local hit = mouse.Target

if hit ~= nil then

if hit.Name == "Build" then

local pc = part:Clone()

pc.Parent = game:GetService("Workspace")
pc.Anchored = true

pc.Position = hit.Position + Vector3.new(0, hit.Size.Y / 2, 0)
pc.Transparency = 0

end
    end 
        end)
            end)

1
Whats the problem exactly here? Kyokamii 133 — 9y
0
I'm trying to make it where you click a part - but I can't figure it out - I just need some help on how to do it. Asperanator -4 — 9y
0
But what's the problem with the script Perci1 4988 — 9y
0
Got skype or accept my fr on ROBLOX so I can message you? Asperanator -4 — 9y
View all comments (3 more)
0
There's no problem I want help on HOW to do it. Asperanator -4 — 9y
0
If there's no problem with your code then it must work. ok good job. Perci1 4988 — 9y
0
Oh my god, I said I want HELP with the above question - read.. Asperanator -4 — 9y

Answer this question