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

I need help with equip and unequipt stuff for my tool?

Asked by 5 years ago

I have tryed lots of functions and they dont work, can you tell me what I exactly have to do? I want it so when my tool is not active to disable this script and when it is active enable it. It doesnt have anything to do it right now. Here is my 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

    while true do
        wait(0.2)
        local part = blankPart:Clone() --never change the original part, only a clone
        part.Parent=workspace
        mouse.TargetFilter=part --ignore the clone while getting mouse position
        local moveConn
        moveConn = mouse.Move:connect(function()
            local p = mouse.Hit.p
            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
        part.Transparency=0
    end

0
connect is deprecated, switch to Connect. :wait is deprecated, switch to :Wait. User#19524 175 — 5y
0
Ok, I did but that doesnt work. protectiverobos -50 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

The problem with your code is, you’re using a while loop, which will run indefinitely. To check if the button is down, use a boolean checking if so.

local mouseDown = false
local connection

connection = mouse.Move:Connect(function() --Connect not connect
    if not mouseDown then
    -- code
    end
end)

mouse.Button1Down:Connect(function()
    mouseDown = true
    connection:Disconnect() --Disconnect not disconnect
end)
0
Should I use the while true do loop inside your code? protectiverobos -50 — 5y
0
No loop. User#19524 175 — 5y
0
It doesnt work. protectiverobos -50 — 5y
0
It put down a stairway, is that suppose to happen?? protectiverobos -50 — 5y
0
It's not working right, are you there? protectiverobos -50 — 5y
Ad

Answer this question