Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Part gets parented multiple times, ideas?

if player and TeleP == false then
            local HE = game.ReplicatedStorage.Effects.BFE:Clone()
            
            TeleP = true
            
            --Make kunai fly
            local BodPos = Instance.new('BodyPosition', RK)
            RK.Anchored = false
        local EnemPos = hit.Parent.HumanoidRootPart
            BodPos.Position = EnemPos.Position
            BodPos.MaxForce = Vector3.new(999999999999999, 99999999999999, 999999999999999)
            BodPos.P = 99999999
            
            

            --TP + Effects
                HE.Parent = game.Workspace
                HE.CFrame = Player.Character.HumanoidRootPart.CFrame
            
            
            
            Player.Character.HumanoidRootPart.CFrame = hit.Parent.HumanoidRootPart.CFrame * CFrame.new(0,0,5)
            Character['Left Arm'].RaijinKunai.Transparency = 0
            HitDetection:Destroy()
            TeleP = false
            end            
        end)        

The "HE" is supposed to be parented once and then the players CFrame to be moved. but even after the players cframe is changed "HE" gets parented to the position after, which is something I don't want. I tried debouncing with the variable "TeleP" but I had no luck.

How can I make the "HE" get parented to workspace once?

2 answers

✓ Accepted answer

try doing this when parenting HE:

if HE.Parent == game.Workspace then
	warn("HE is already parented to workspace.")
else
	HE.Parent = game.Workspace
end

Hope this helps!

as i see here, youre not using wait() while debounce so i think you need to make wait() inside your script between the debounce true and false

This discussion is preserved as it was. New answers, comments, and votes are closed.