Tween only working once

I am new to scripting so sorry if the following sounds dumb to you

  1. What do you want to achieve? Keep it simple and clear!

I want to change the orientation of a sword (on clients) using tweenservice everytime someone triggers a proximity prompt

  1. What is the issue? Include screenshots / videos if possible!

The orientation only changes the first time

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I haven’t found a solution here so I tried print something when the tween was completed and it worked everytime unlike the tween itself

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!


local Remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local Sword1 = game.Workspace:WaitForChild("Sword1")
local Tween = game:GetService("TweenService"):Create(Sword1, TweenInfo.new(4, Enum.EasingStyle.Bounce), {Orientation = Sword1.Orientation + Vector3.new(90, 0, 0)})

Remote.OnClientEvent:Connect(function()
   Tween:Play()
end)
2 Likes

It’s because it’s tweening to the place it’s already in. You have to make another tween or reset it to another position so the tween plays - it exists, but it isn’t actually rendering due to the fact it’s just going to the position it already was in - which is redundant.

2 Likes

How about trying this one;

local tween_service = game:GetService("TweenService")
local replicated_storage = game:GetService("ReplicatedStorage")

local info = TweenInfo.new(4, Enum.EasingStyle.Bounce)

local remote_event = replicated_storage:WaitForChild("RemoteEvent")
local sword_1 = workspace:WaitForChild("Sword1")

remote_event.OnClientEvent:Connect(function()
	tween_service:Create(sword_1, info, {Orientation = sword_1.Orientation + Vector3.new(90, 0, 0)}):Play()
end)

Make sure when creating a tween and making it into a variable outside any functions, the property that It knew is the property when you started the game.

But here, It always creates a tween when the remote event has been fired so the property it knew is getting updated every fire of the remote event.

Also, did some organization and optimization.

1 Like

Ooh thanks for clearing it up !

It worked ! Thanks for the help !

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.