I’m trying to make a block that makes an angry face, smashes down, then becomes more calm and rises up, repeating the process, similar to a Thwomp in Super Mario.
However, when I attempt to change the faces at the right time, this is usually the result:
And that’s what happens when I run the game. When I test it as a client, the faces may have a different result, or the faces change with perfect timing, but the opposite faces appear instead, and I cannot find the problem in the script.
This is the script.
--Variables
local TweenService = game:GetService("TweenService")
local smashPart = script.Parent
local pos = smashPart.Position
local newPos = pos + Vector3.new(0, -17, 0)
local angry1 = smashPart.Angry1
local angry2 = smashPart.Angry2
local angry3 = smashPart.Angry3
local angry4 = smashPart.Angry4
local idle1 = smashPart.Idle1
local idle2 = smashPart.Idle2
local idle3 = smashPart.Idle3
local idle4 = smashPart.Idle4
local tweenInfo = TweenInfo.new(
1.25, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
3 -- DelayTime
)
local tweenInfo2 = TweenInfo.new(
1.25, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
2 -- DelayTime
)
local tweenFall = TweenService:Create(smashPart, tweenInfo, {Position = newPos})
local tweenUp = TweenService:Create(smashPart, tweenInfo2, {Position = pos})
--Tweens
tweenFall:Play() --Starts the fall tween
tweenFall.Completed:Connect(function()
tweenUp:Play() --Play the up tween when the fall tween is finished
end)
tweenUp.Completed:Connect(function()
tweenFall:Play() --Play the fall tween when the up tween is finished
end)
--Looping the faces
while true do
--The fall tween will play in 3 seconds
angry1.Transparency = 1
angry2.Transparency = 1
angry3.Transparency = 1
angry4.Transparency = 1 --Making angry faces disappear
idle1.Transparency = 0
idle2.Transparency = 0
idle3.Transparency = 0
idle4.Transparency = 0 --Making the idle faces appear
print("test")
wait(3)
--The fall tween will play
angry1.Transparency = 0
angry2.Transparency = 0
angry3.Transparency = 0
angry4.Transparency = 0 --Making angry faces appear
idle1.Transparency = 1
idle2.Transparency = 1
idle3.Transparency = 1
idle4.Transparency = 1 --Making the idle faces disappear
print("test")
wait(1.25)
--The fall tween ends
wait(2)
--The up tween will begin
angry1.Transparency = 1
angry2.Transparency = 1
angry3.Transparency = 1
angry4.Transparency = 1 --Making angry faces disappear
idle1.Transparency = 0
idle2.Transparency = 0
idle3.Transparency = 0
idle4.Transparency = 0 --Making the idle faces appear
print("test")
wait(1.25)
--The up tween ends
end
-
What do you want to achieve? I want to make a part crash down and to change it’s faces when it does.
-
What is the issue? The faces are not changing in sync with the tweens, and I cannot figure out why.
-
What solutions have you tried so far? I searched for similar topics, but I couldn’t find anything relevant to my issue.
I have includes comments with the wait()'s, and thought it through many times, but I still couldn’t figure out why the faces weren’t changing with good timing.
Edit: I’m not tweening the faces, I’m tweening the position of the part.