Hi noob at scripting i’m wondering how i’d convert this script so it works as a button on and off instead of click mouse with tool selected?
function changeTransparency(parentModel, partName, transparency)
local C = parentModel:GetChildren()
for i=1, #C do
if C[i].className == "Model" then
local CM = C[i]:GetChildren()
for j=1, #CM do
if CM[j].className == "Part" and CM[j].Name == partName then
--script.Parent.Parent.Parent.Character.Chest.A8.CanCollide=false
CM[j].Transparency = transparency
end
end
end
end
end
function onSelected(mouse)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
mouse.Button1Up:connect(function() onButton1Up(mouse) end)
mouse.Icon = "rbxasset://textures\\GunCursor.png"
end
script.Parent.Selected:connect(onSelected)
function onDeselected(mouse)
end
script.Parent.Deselected:connect(onDeselected)
function onSelected(mouse)
changeTransparency(script.Parent.Parent.Parent.Character,"Part",1)
changeTransparency(script.Parent.Parent.Parent.Character,"Middle",1)
changeTransparency(script.Parent.Parent.Parent.Character,"Quarter Sphere",1)
changeTransparency(script.Parent.Parent.Parent.Character,"Ring",1)
changeTransparency(script.Parent.Parent.Parent.Character,"Middle",1)
changeTransparency(script.Parent.Parent.Parent.Character,"Smooth Block Model",1)
wait(0)
changeTransparency(script.Parent.Parent.Parent.Character,"Bird",0)
end
function onDeselected(mouse)
changeTransparency(script.Parent.Parent.Parent.Character,"Part",0)
changeTransparency(script.Parent.Parent.Parent.Character,"Middle",0)
changeTransparency(script.Parent.Parent.Parent.Character,"Quarter Sphere",0)
changeTransparency(script.Parent.Parent.Parent.Character,"Ring",0)
changeTransparency(script.Parent.Parent.Parent.Character,"Middle",0)
changeTransparency(script.Parent.Parent.Parent.Character,"Smooth Block Model",0)
wait(0)
changeTransparency(script.Parent.Parent.Parent.Character,"Bird",1)
Player.Head.face.Transparency = 0
end
script.Parent.Deselected:connect(onDeselected)
script.Parent.Selected:connect(onSelected)