Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 comments

0

connect is deprecated, switch to Connect. :wait is deprecated, switch to :Wait.

0

Ok, I did but that doesnt work.

1 answer

✓ Accepted answer

###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)

5 comments

0

Should I use the while true do loop inside your code?

0

No loop.

0

It doesnt work.

0

It put down a stairway, is that suppose to happen??

0

It's not working right, are you there?

This discussion is preserved as it was. New answers, comments, and votes are closed.