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

Can somene help me with my block placer script thats not working right?

Asked by 5 years ago
Edited 5 years ago

I want to make it so my tool can place blocks when its equipped and cant when its unequipped. But I want it to place a lot of blocks and not just one. Right now the problem is when I move the mouse it keep creating more can this get fixed and still work the way I want it to?

code...

    wait(2)
    local player = game.Players.LocalPlayer
    local mouse = player:GetMouse()
    local blankPart = game.Players.LocalPlayer.PlayerGui.BlockGui.Block.Part
    blankPart.Anchored=true
    blankPart.CanCollide=false
    blankPart.Transparency=0.75

    local connection



    connection = mouse.Move:Connect(function() --If the mouse moves
            wait(0.1)
            local part = blankPart:Clone() --Clone part
            part.Parent=workspace  --Parent = workspace
            mouse.TargetFilter=part --ignore the clone while getting mouse position
            local moveConn  --Variable move connect
            moveConn = mouse.Move:Connect(function() -- Mouse -- moves function
                local p = mouse.Hit.p  -- Mouse click position
                part.Position = Vector3.new(math.floor(p.X),math.ceil(p.Y),math.floor(p.Z)) --mouse position in whole numbers
            end)
            mouse.Button1Down:Wait() --Do not have to connect a click function :)


            moveConn:Disconnect() --Stop moving the clone
            part.CanCollide=true  --Can collide = true
            part.Transparency=0  --Transperancy = 0
    end)
0
You need a MouseHeld bool value awesomeipod 607 — 5y
0
So how would I do that? protectiverobos -50 — 5y

Answer this question