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

I need help to make it so my build tool only works when I have it equipped?

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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

0
Can show show me what I would use? protectiverobos -50 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Hello, use .Activated instead of mouse.Button1Down.

Here is the roblox documention

0
So Mouse.Activated? protectiverobos -50 — 6y
0
It says Activated is not a valid member of PlayerMouse protectiverobos -50 — 6y
0
No, Tool.Activated. User#19524 175 — 6y

Answer this question