Tween is not working

So im trying to tween a slash attack but it isn’t working, why is this happening?

local Player = game.Players.LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local root = character:WaitForChild("HumanoidRootPart")
local head = character:WaitForChild("Head")

local tweenservice = game:GetService("TweenService")

game.ReplicatedStorage.Events.Effects.OnClientEvent:Connect(function(status)
	if status == "Slash" then
		local slash = game.ReplicatedStorage:WaitForChild("slash"):Clone()
		slash.Parent = workspace
		slash.CFrame = root.CFrame * CFrame.new(0,0,2) * CFrame.Angles(0,math.rad(180),0)
		
		local goal = {}
		goal.Size = Vector3.new(3.958, 0.05, 9.569)
		goal.Transparency = 1
		
		local tweentime = TweenInfo.new(1)
		local tween = tweenservice:Create(slash, tweentime, goal):Play()
	elseif status == "SlashSmall" then
		local slash = game.ReplicatedStorage:WaitForChild("slash"):Clone()
		slash.Parent = workspace
		slash.CFrame = root.CFrame * CFrame.new(0,2,2) * CFrame.Angles(0,math.rad(90),0)
		
		local goal = {}
		goal.Size = Vector3.new(7.562, 0.05, 12.45)
		goal.Transparency = 1
		
		local tweentime = TweenInfo.new(1)
		tweenservice:Create(slash, tweentime, goal):Play()
	end
end)

Thank you

1 Like

I think its because you put the tween in a variable, you can remove the variable and have this tweenservice:Create(slash, tweentime, goal):Play()

1 Like

Is the slash unachored? I think you may need to anchor it and then remove it once the tween ends

Also this

local tween = tweenservice:Create(slash, tweentime, goal):Play()

In your first if statement shoudl be this

tweenservice:Create(slash, tweentime, goal):Play()

If that makes a difference

thanks for pointing that out but this still didn’t fix it

yes, it’s unanchored

I think you have to make it anchored then and destroy it once the tween ends. Try this?

local Player = game.Players.LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local root = character:WaitForChild("HumanoidRootPart")
local head = character:WaitForChild("Head")

local tweenservice = game:GetService("TweenService")

game.ReplicatedStorage.Events.Effects.OnClientEvent:Connect(function(status)
	if status == "Slash" then
		local slash = game.ReplicatedStorage:WaitForChild("slash"):Clone()
		slash.Anchored = true
		slash.Parent = workspace
		slash.CFrame = root.CFrame * CFrame.new(0,0,2) * CFrame.Angles(0,math.rad(180),0)
		
		local goal = {}
		goal.Size = Vector3.new(3.958, 0.05, 9.569)
		goal.Transparency = 1
		
		local tweentime = TweenInfo.new(1)
		local tween = tweenservice:Create(slash, tweentime, goal)
		tween:Play()
		tween.Completed:Wait()
		slash:Destroy()
	elseif status == "SlashSmall" then
		local slash = game.ReplicatedStorage:WaitForChild("slash"):Clone()
		slash.Anchored = true
		slash.Parent = workspace
		slash.CFrame = root.CFrame * CFrame.new(0,2,2) * CFrame.Angles(0,math.rad(90),0)
		
		local goal = {}
		goal.Size = Vector3.new(7.562, 0.05, 12.45)
		goal.Transparency = 1
		
		local tweentime = TweenInfo.new(1)
		local tween = tweenservice:Create(slash, tweentime, goal)
		tween:Play()
		tween.Completed:Wait()
		slash:Destroy()
	end
end)

I don’t think the problem is with the tween, I think it’s got to do with the CFrame. I’m not really that good in that topic, but that is where I assume the problem would be.

This is whats happening now

I think you did the CFraming incorrectly, you may need t otweak it so it’s pointing at where you’re facing

It doesn’t make a difference. If you want to access the Completed event then the second option should be used.

Yes that is now confirmed that it doesn’t make a difference and it has to be in a variable now to use the Completed event after playing the tween as stated in my recent example.

@NotZylon Did you get any errors by the way? If not, then the only real issue left is probably the CFraming needing to be tweaked a bit so it points to where you’re facing

1 Like

Alright, thanks for the help. I will just create a new script

1 Like

Alright, if that’s more beneficial to you yourself then it should be no worries! If you ever have anymore issues don’t be afraid to make another post!

Although You’d just have to change the CFrame around to make it finally work, but if there’s any more underlying issues then yea probably starting over may be the better approach

1 Like