You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? an ability that makes the player’s transparency 0.5
What is the issue? not all base parts’ canCollide is being set to false and transparency doesnt work
What solutions have you tried so far? I would write out each body part but that would be time consuming and I haven’t found a way on the dev hub to achieve my goal.
LocalScript
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.B then
script.Fire:FireServer()
end
end)
ServerScript (child of LocalScript)
script.Parent.Fire.OnServerEvent:Connect(function(player)
enabled = false
if not enabled then return end
local char = player.Character
local children = char:GetChildren()
for i, v in pairs(children) do
if v:IsA("BasePart") and v.Name == "LowerTorso" then
v.Transparency = 0.5
v.CanCollide = false
end
end
wait (10)
for i, v in pairs(children) do
if v:IsA("BasePart") and v.Name == "LowerTorso" then
v.Transparency = 0
v.CanCollide = true
end
end
wait (5)
enabled = true
end)
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.B then
game:GetService("ReplicatedStorage").Fire:FireServer() -- Make sure you have the paths correct. Keep remote events in replicatedstorage.
end
end)
game:GetService("ReplicatedStorage").Fire.OnServerEvent:Connect(function(player) -- Fix remote paths. Always double check
local enabled = true -- Your debounce was the other way around.
if not enabled then return end
local char = player.Character
local children = char:GetChildren()
for i, v in pairs(children) do
if v:IsA("BasePart") then -- Not sure why you were also filtering for lowertorso if you want the whole body
v.Transparency = 0.5
v.CanCollide = false
end
end
wait (1)
for i, v in pairs(children) do
if v:IsA("BasePart") then
v.Transparency = 0
v.CanCollide = true
end
end
wait (1) -- When experimenting, try removing unnecessary delays so that you can debug easily. Revert the delay values back when you got it working
enabled = false
end)
Put remote event “Fire” inside replicatedstorage.
For future questions please include your error message so you get your solution faster. It helps the person helping you more. Make sure you double check. Seems like you took it off of the internet and just pasted it in the dev forum asking for it to be rewritten to work with your scenario. Put some effort into it.
Other than that, fixed it up for you.