Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[UNSOLVED] Spamming output even with Delay's?

Asked by 8 years ago
Edited 8 years ago

I've created an orb the follows you around, and had fixed my previous problem of the orb and it's casing being out on sync by welding them.

The problem now is that when it creates the weld, it spams it (which appears to be lagging it), and I have no clue how to fix it.

I've tried Wait() and Variables, yet it just keeps on spamming.

Here is the looped Code:

                while wait() do
            BP.Position = Character:FindFirstChild("Torso").CFrame * CFrame.new(1.7,1.7,1.2).p
            BP2.Position = Character:FindFirstChild("Torso").CFrame * CFrame.new(1.7,1.7,1.2).p
            local PetInvisibleEvent = game.Workspace.PetInvisibleEvent
            PetInvisibleEvent.OnServerEvent:connect(function()
                OrbPet.Transparency = .2
                OrbPetCase.Transparency = .6
                wait(.005)
                OrbPet.Transparency = .4
                wait(.005)
                OrbPet.Transparency = .6
                wait(.005)
                OrbPet.Transparency = .8
                wait(.005)
                OrbPet.Transparency = .1
                OrbPetCase.Transparency = .1
                OrbPet.Parent = game:GetService("ServerStorage")
            end)
            local PetVisibleEvent = game.Workspace.PetVisibleEvent
            PetVisibleEvent.OnServerEvent:connect(function()
                OrbPet.Parent = Character
                OrbPet.Position = Character:FindFirstChild("Torso").CFrame * CFrame.new(2,2,1.4).p
                OrbPetCase.Position = Character:FindFirstChild("Torso").CFrame * CFrame.new(2,2,1.4).p
                OrbPet.Transparency = .8
                OrbPetCase.Transparency = .6
                wait(.005)
                OrbPet.Transparency = .6
                wait(.005)
                OrbPet.Transparency = .4
                wait(.005)
                OrbPet.Transparency = .2
                wait(.005)
                OrbPet.Transparency = .0
                local Weld = Instance.new("ManualWeld",OrbPet)
                Weld.Part0 = OrbPet
                Weld.Part1 = OrbPetCase
                Weld.C0 = CFrame.new(0,0,0)
            end)
        end

Please help,

Kyleo

0
Try moving the event connections outside the loop? honeygold13843 136 — 8y
0
I'll try it... Kyleocraft 25 — 8y
0
It doesn't work when it's outside of the loop... Kyleocraft 25 — 8y

Answer this question