local playerz = game.Players.LocalPlayer local character = playerz.Character local uis = game:GetService("UserInputService") local bodyparts = character:GetChildren() uis.InputBegan:Connect(function(input, gameProcessedEvent) if uis.KeyboardEnabled then print("E") if input.KeyCode == Enum.KeyCode.B then character = playerz.CharacterAdded:wait() for i, v in pairs(bodyparts) do if bodyparts:IsA("BasePart") then bodyparts.Transparency =1 end end end end end)
Trying to figure out why this code dosent work but im puzzled the code prints E since im on Studio using Keyboard but it wont go on to the next if statements of they straight up dont work
It should work in a local script if you type the following.
local player = game.Players.LocalPLayer local character = player.CharacterAdded:Wait() local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input, gameProcessedEvent) if input.UserInputType == Enum.UserInputType.Keyboard then if input.KeyCode == Enum.KeyCode.E then for i,v in pairs (character:GetChildren()) do if v:IsA("BasePart") then v.Transparency = 1 end end end end end
I believe your error was in checking if "bodyparts" (character:GetChildren()) was a basepart instead of v (each individual child).