local debounce = true script.Parent.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player and hit.Parent:FindFirstChild("Humanoid") then if debounce then debounce = false while script.Parent.Transparency <= 1 do script.Parent.Transparency = script.Parent.Transparency + 0.01 wait(0.01) end script.Parent.CanCollide = false wait(3) script.Parent.CanCollide = true script.Parent.Transparency = 0 debounce = true end end end)
Local scripts don't work in workspace, so you can't put this script in there. I can't seem to find any idea to solve it.
There is something called StarterPlayerScripts in StarterPlayer, put a local script in there and check if the brick is touched from there.
local Bricks = workspace.Bricks:GetChildren() local debounce = true for i,v in ipairs(Bricks) do v.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player and hit.Parent:FindFirstChild("Humanoid") then if debounce then debounce = false while v.Transparency <= 1 do v.Transparency = v.Transparency + 0.01 wait(0.01) end v.CanCollide = false wait(3) v.CanCollide = true v.Transparency = 0 debounce = true end end end) end
I'm fairly sure you can put local scripts in the workspace, if you are trying to detect if just the local player touches it, you would have to modify it a bit, perhaps like this:
local debounce = true script.Parent.Touched:Connect(function(hit) local player = game.Players.LocalPlayer if hit.Parent:FindFirstChild("Humanoid") then if debounce then debounce = false while script.Parent.Transparency <= 1 do script.Parent.Transparency = script.Parent.Transparency + 0.01 wait(0.01) end script.Parent.CanCollide = false wait(3) script.Parent.CanCollide = true script.Parent.Transparency = 0 debounce = true end end end)
The reason ur script doesnt work because local scripts dont use :GetPlayerFromCharacter() There are some other bugs but ill give u the fixed script for u that will work in workspace
local debounce = true script.Parent.Touched:Connect(function() local player = game.Players.LocalPlayer if debounce then debounce = false script.Parent.CanCollide = false wait(3) script.Parent.CanCollide = true script.Parent.Transparency = 0 debounce = true while script.Parent.Transparency <= 1 do script.Parent.Transparency = script.Parent.Transparency + 0.01 wait(0.01) end end end)