local Part = script.Parent
Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
Part.Transparency = .9
Part.CanCollide = false
Part.GlassShatter = true -- GlassShatter is particle emitter
Part.GlassShatter.Rate = 100
Part.GlassShatter.Life = NumberRange.new(1,1)
end
end)
print("Hit")
local Part = game.Workspace.Part:ClearAllChildren()
When I run the game, it prints “hit” when no character is present, what may be the cause of this?
Alright. I’m trying to emit the particle when somebody steps on it and then make the particle disappear. I understand the mistake with the print, but the function seems to run when nobody hits it.
I think your confused, the stuff after the function (outside of it) can still run even though the part hasn’t been touched, try this script:
local Part = script.Parent
Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
Part.Transparency = .9
Part.CanCollide = false
Part.GlassShatter = true -- GlassShatter is particle emitter
Part.GlassShatter.Rate = 100
Part.GlassShatter.Life = NumberRange.new(1,1)
print("Hit")
local Part = game.Workspace.Part:ClearAllChildren()
end
end)