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 to make it so my build tool only works when I have it equipped?

Heres my code... I tried editing it, but then it ends up not working.

wait(0.1)
    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 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
	    mouse.Button1Down:wait() --do not have to connect a click function :)
	    part.CanCollide=true
	    part.Transparency=0
end

2 answers

✓ Accepted answer

what ou must do is make it so when equipped it works then when .unequipped it doesnt work, to do this, use two scripts, one is equipped, one unequipped (names)both start disabled = false(enabled), so enabled named if you want script is

-script.Parent(tool).Equipped:connect(function() (whaever it does here, or if its another script the building is in do this:)

-script.Parent.Equipped:Connect(function() script.Parent.BuildScript(or whatever its called).Disabled = false(enables it) script.Disabled = true(disables current script)

REMEMEBR, DISABLE THE CURRENT SCRIPT AFTER, IF FIRST IT WONT DO NEXT LINES OF SCRiPT!!! and unequipped script says something like

-script.Parent.Unequipped:connect(function() while true do(keeps checking every time) if script.Parent.Equipped then (if equipped triggers this->) script.Parent.equipped.Disabled = false (enables) (REMEMEBER DISABLE CURRENT SCRIPT LAST!! LAST LAS LAST!!!!!:( )' script.Disabled = true else script.Parent.Buildscript(for example).Disabled = true(it wont work now) wait(.1) end

Im a little off today, its late and im lazy and its hard to think, but hope this helps :) -Noob189012, experianced scripter and builder

1 comment

0

Can show show me what I would use?

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