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

How would i make this script only visible when a tool is equipped?

Asked by
exarlus 72
6 years ago

So basically this script creates fake arms so i want the arms to be visible the player equips a tool and i want it to turn invisible again when a player unequips a tool.

wait(3)
lp = game.Players.LocalPlayer
p = lp.Character
p:WaitForChild("Body Colors")
larm = p['LeftLowerArm']
rarm = p['RightLowerArm']

l = Instance.new("Part",workspace.CurrentCamera)

l.FormFactor = "Custom"
l.BrickColor = p['Body Colors'].LeftArmColor
l.Material = "SmoothPlastic"
l.CanCollide = false


r = Instance.new("Part",workspace.CurrentCamera)
r.FormFactor = "Custom"
r.BrickColor = p['Body Colors'].RightArmColor
r.Material = "SmoothPlastic"
r.CanCollide = false


script.Parent.left.Value = l
script.Parent.right.Value = r



l.Size = Vector3.new(0.89, 1.94, 0.91)   
l.CFrame  = larm.CFrame

r.Size = Vector3.new(0.89, 1.94, 0.91)
r.CFrame = rarm.CFrame


lw = Instance.new("Weld",l)
lw.Part0 = l
lw.Part1 = p['LeftLowerArm']


rw = Instance.new("Weld",r)
rw.Part0 = r
rw.Part1 = p['RightLowerArm']


r.Name = (lp.Name.."'s extra right arm")
l.Name = (lp.Name.."'s extra left arm")
while wait() do
    l.BrickColor = p['Body Colors'].LeftArmColor
    r.BrickColor = p['Body Colors'].RightArmColor


script.Parent.MouseButton1Down:connect(function()
    if l.Transparency == 1 then
        l.Transparency = 0
        r.Transparency = 0
    elseif l.Transparency == 0 then 
        l.Transparency = 1
        r.Transparency = 1

    else
    print("ERROR")

    l.Transparency = 0
    r.Transparency = 0
    end

end)

p.Humanoid.Died:connect(function()
    larm.Transparency = 0
    rarm.Transparency = 0
    l:Destroy()
    r:Destroy()
end)
end
0
You have to make a onEquip() function in the tool using a local script and make the function activate this script. hellmatic 1523 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Put this in a local script in the tool :)

script.Parent.Equipped:connect(function()
wait(3)
local lp = game.Players.LocalPlayer
local p = lp.Character
p:WaitForChild("Body Colors")
larm = p['LeftLowerArm']
rarm = p['RightLowerArm']

l = Instance.new("Part",workspace.CurrentCamera)

l.FormFactor = "Custom"
l.BrickColor = p['Body Colors'].LeftArmColor
l.Material = "SmoothPlastic"
l.CanCollide = false


r = Instance.new("Part",workspace.CurrentCamera)
r.FormFactor = "Custom"
r.BrickColor = p['Body Colors'].RightArmColor
r.Material = "SmoothPlastic"
r.CanCollide = false


script.Parent.left.Value = l
script.Parent.right.Value = r



l.Size = Vector3.new(0.89, 1.94, 0.91)   
l.CFrame  = larm.CFrame

r.Size = Vector3.new(0.89, 1.94, 0.91)
r.CFrame = rarm.CFrame


local lw = Instance.new("Weld",l)
lw.Part0 = l
lw.Part1 = p['LeftLowerArm']


local rw = Instance.new("Weld",r)
rw.Part0 = r
rw.Part1 = p['RightLowerArm']


r.Name = (lp.Name.."'s extra right arm")
l.Name = (lp.Name.."'s extra left arm")
while wait() do
    l.BrickColor = p['Body Colors'].LeftArmColor
    r.BrickColor = p['Body Colors'].RightArmColor
end
script.Parent.MouseButton1Down:connect(function()
    if l.Transparency == 1 then
        l.Transparency = 0
        r.Transparency = 0
    elseif l.Transparency == 0 then 
        l.Transparency = 1
        r.Transparency = 1

    else
    print("ERROR")

    l.Transparency = 0
    r.Transparency = 0
    end
end)

p.Humanoid.Died:connect(function()
    larm.Transparency = 0
    rarm.Transparency = 0
    l:Destroy()
    r:Destroy()
end)
end)

script.Parent.Unequipped:connect(function()
    larm.Transparency = 0
    rarm.Transparency = 0
    l:Destroy()
    r:Destroy()
end)

Worked fine for me! Nice script btw :P

0
Thanks it worked! exarlus 72 — 6y
0
Glad I could help! DanielDeJong3 158 — 6y
Ad

Answer this question