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

why wont my script destroy this part?

P = Instance.new('Part')
P.Parent = workspace
P.Name = 'Chock'
tweenService = game:GetService('TweenService')

tweeninginfromation = TweenInfo.new(
10,
Enum.EasingStyle.Linear, 
Enum.EasingDirection.Out,
10,
true,
1


)

local partProperties = {
	Size = Vector3.new(100,100,100),
	
	
}

local Tween = tweenService:Create(P,tweeninginfromation,partProperties)
Tween:Play()
while wait() do
	P.Transparency = P.Transparency + .02
	if P.Transparency ==1 then
		P:Destroy()
	end
end

2 comments

0

No context. Please add more info

1

why not alsi include the Transparency in the tween the delete the part when the tween has finished.

1 answer

Never use == when working with decimals, always use >= or <=

P = Instance.new('Part')
P.Parent = workspace
P.Name = 'Chock'
tweenService = game:GetService('TweenService')

tweeninginfromation = TweenInfo.new(
10,
Enum.EasingStyle.Linear, 
Enum.EasingDirection.Out,
10,
true,
1


)

local partProperties = {
    Size = Vector3.new(100,100,100),


}

local Tween = tweenService:Create(P,tweeninginfromation,partProperties)
Tween:Play()
while wait() do
    P.Transparency = P.Transparency + .02
    if P.Transparency >= 1 then
        P:Destroy()
    end
end


5 comments

1

local VARIABLE = VALUE, not VARIABLE = VALUE also use while true do wait() end, not while wait() do end

0

While both of the above are not required for working code, I highly suggest you follow them because they are good practice.

0

also it is >=, not =>

0

Jesus christ yHasteeD. being broad in your comments. Not very helpful.

0

You'll notice i just copied his code, and didnt bother fixing the irrelevent pieces. I answered the question, im not required to analyze and correct every piece of it. The issue was corrected and sufficiently explained.

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