Hey. I have detected a few errors that you need to fix for the script to work.
- Do not call LocalPlayer on a server script, it would return an error.
- Connect the function to everytime the character is added, as the character not being present will result in an error.
- You need not write the code to change the transparency for every single part. Also, using this method would error in R6. Use just a for ... do loop to look through the parts which are either Part, MeshPart or UnionOperation.
- Use the Humanoid:GetAccessories() Method to get the accessories. This ensures that all accessories are returned.
- Accessories do not have a transparency property. Change their Handle's Transparency instead.
- The wait() is outside the condition check, which lets it run anyway. Put that inside the conditional block.
I'm gonna leave my version of your script here, which might help you understand it a bit better.
Parent this to ServerScriptService.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Player.Chatted:Connect(function(msg)
if msg == "invisique" then
for _,BodyPart in pairs(Character:GetChildren()) do
if BodyPart:IsA("Part") or BodyPart:IsA("UnionOperation") or BodyPart:IsA("MeshPart") then
BodyPart.Transparency = 1
end
end
for _,Accessory in pairs(Humanoid:GetAccessories()) do
Accessory.Handle.Transparency = 1
end
wait(10)
for _,BodyPart in pairs(Character:GetChildren()) do
if BodyPart:IsA("Part") or BodyPart:IsA("UnionOperation") or BodyPart:IsA("MeshPart") then
if BodyPart.Name ~= "HumanoidRootPart" then BodyPart.Transparency = 0 end
end
end
for _,Accessory in pairs(Humanoid:GetAccessories()) do
Accessory.Handle.Transparency = 0
end
end
end)
end)
end)