color = script.Parent.BrickColor debounce = false script.Parent.Touched:connect(function(part) local h = part.Parent:FindFirstChild("Humanoid") if h and (h.WalkSpeed == 3) and (not debounce) then h:TakeDamage(0) elseif h and (not debounce) then debounce = true h:TakeDamage(2) local function r() return math.random(0.1, 0.5) end local BodyParts = {h.Parent["Right Arm"], h.Parent["Left Arm"], h.Parent.Torso, h.Parent["Left Leg"], h.Parent["Right Leg"]} local BodyPart = BodyParts[math.random(1, 5)] local Shard = Instance.new("Part") local Crystal = Instance.new("SpecialMesh") Crystal.MeshId = "http://www.roblox.com/Asset/?id=9756362" Crystal.Parent = Shard Crystal.Scale = Vector3.new(0.5, 0.25, 3) Shard.Parent = BodyPart Shard.CFrame = BodyPart.CFrame * CFrame.Angles(0, 0, 0) Shard.BrickColor = color Shard.CanCollide = false local w = Instance.new("Weld") w.Part0 = Shard w.Part1 = BodyPart w.C0 = CFrame.new(0, 0, 0) * CFrame.Angles(r(), r(), r()) w.Parent = Shard wait(3) -- Problem1 for i = 1, 10 do Shard.Transparency = Shard.Transparency + 0.2 wait(0.1) end wait(5) -- Problem2 Shard:Destroy() end end) Shot = script.Parent wait(1) Shot:Destroy()
Everything works fine until I add the wait()
. Please help.