I have these scripts for a tool that makes you invisible, and a med kit. Apparently, the way they use attributes to change the player’s colors and transparencies somehow interfere. The functions I initialize in the scripts fire upon equipping the tools, and I have no idea what is going on.
they are server scripts and they are placed inside the tools.
Shadow Sphere (invisibility tool) script:
local me = script.Parent
local handle = me.Handle
local debounce = false
local hogtran = handle.Transparency
local function transparent(char)
for _, part in pairs(char:GetChildren()) do
if part:IsA("BasePart") then
part:SetAttribute("transparency", part.Transparency)
part.Transparency = 1
end
end
local torso = char:FindFirstChild("Torso")
torso.Trail.Enabled = false
handle.Transparency = 1
end
local function opaque(char)
for _, part in pairs(char:GetChildren()) do
if part:IsA("BasePart") then
local transparency = part:GetAttribute("transparency")
part.Transparency = transparency
print(transparency)
end
end
local torso = char:FindFirstChild("Torso")
torso.Trail.Enabled = true
handle.Transparency = hogtran
end
me.Activated:Connect(function()
if debounce == false then
debounce = true
local char = me.Parent
transparent(char)
handle["Shoulder fired rocket.wav"]:Play()
handle.Transparency = 1
task.wait(5)
handle["time up"]:Play()
opaque(char)
debounce = false
end
end)
me.Unequipped:Connect(function()
local char = me.Parent.Parent.Character
opaque(char)
if debounce == true then
handle.interrupt:Play()
end
end)
Med kit script:
local me = script.Parent
local handle = me.Handle
local anim = me.Animation
local debounce = false
local function bandage(char)
for _, part in pairs(char:GetChildren()) do
if part:IsA("BasePart") then
part:SetAttribute("ogcolor", part.Color)
part.Color = Color3.new(1,1,1)
end
end
end
local function normalize(char)
for _, otherpart in pairs(char:GetChildren()) do
if otherpart:IsA("BasePart") then
otherpart.Color = otherpart:GetAttribute("ogcolor")
end
end
end
me.Activated:Connect(function()
if debounce == false then
debounce = true
local char = me.Parent
local hum = char:FindFirstChild("Humanoid")
local animer = hum:FindFirstChild("Animator")
if animer:IsA("Animator") then
local track = animer:LoadAnimation(anim)
track:Play()
track:GetMarkerReachedSignal("eat"):Wait()
handle.Transparency = 1
handle["red-cross-black-outline"].Transparency = 1
handle.Chewing:Play()
bandage(char)
task.wait(2)
hum.Health = hum.Health + 100
normalize(char)
me:Destroy()
end
end
end)