TweenService and LookVector not working

I’m trying to make a script that makes loot randomly pop up in front of a chest.
However, whenever the script runs the part does not move at all.

Problem:
https://i.gyazo.com/2011d0dd99711b06446bd6b187568dbb.gif
The sword should move forward in front of the chest but instead stays in place. Changing the value seems to have no effect at all. The Y value seems to work fine so the problem is with the LookVector parts. This is my first time using Tweens and LookVector, so any help would be much appreciated!

local prompt = script.Parent.Parent.ProximityPrompt
local promptservice = game:GetService("ProximityPromptService")
local serverstorage = game:GetService("ServerStorage")
prompt.Triggered:Connect(function(player)
	local Chest = script.Parent.Parent.Parent.Parent
	local Lid = Chest.Top
	Lid.PrimaryPart = Lid.Hinge1
	Lid:SetPrimaryPartCFrame(Lid.Hinge1.CFrame * CFrame.fromEulerAnglesXYZ(0,0,80))
	prompt.Enabled = false
		local reward2 = serverstorage.ChestRewards.RandomSword:Clone()
		reward2.Parent = workspace
	reward2.Base.CFrame = Chest.Bottom.SwordThing1.CFrame
	
	local TweenService = game:GetService("TweenService")
	
	local TweenInfo = TweenInfo.new(1, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out,0, false, 0)
	
	local Goal = {Position =  reward2.Base.Position +  Vector3.new(Chest.Bottom.SwordThing1.CFrame.LookVector * 2,-0.5,Chest.Bottom.SwordThing1.CFrame.LookVector * 4)}
	
		local tweener = TweenService:Create(reward2.Base, TweenInfo , Goal):Play()
end)
1 Like

Where is the code for the rotating of the sword?

1 Like

The code for rotating the sword is on a separate script. However, my goal is to move the sword based on the direction “SwordThing1” is facing.
I’ll attach the code anyways, however I’m not sure if it applies here.

while true do 
	wait()
	base.CFrame = base.CFrame * CFrame.Angles(0, math.rad(10), 0)
end
1 Like

Perhaps the problem is on this line, try playing the tween on a seperate line.

1 Like

Exact same problem still occurs.

1 Like

The problem may be the position the tween is setting it to, try seeing where the position that the tween is setting it to is the correct one.

1 Like

I’m closer, but the problem still persists! I realize now that LookVector is only trying to make changes to 1 axis. Both are trying to edit the same axis. However, even with just 1 LookVector it still doesn’t move.

1 Like

Blockquote
local tweener = TweenService:Create(reward2.Base, TweenInfo , Goal):Play()
end)

Perhaps this may be the problem. You must first declare the tweener variable on its own, then call the play method on the variable in order for the tween to play.
Something like this may work:

Blockquote
local tweener = TweenService:Create(reward2.Base, TweenInfo , Goal)
tweener:Play()

1 Like

I’ve suggested this but OP said the problem still persists

1 Like

Oh, sorry about that! Didn’t see your reply before.

I see the problem now:

Blockquote
local Goal = {Position = reward2.Base.Position + Vector3.new(Chest.Bottom.SwordThing1.CFrame.LookVector * 2,-0.5,Chest.Bottom.SwordThing1.CFrame.LookVector * 4)

You are using a look vector inside the x and z components of the Vector3.new. I assume that you meant to do this:

Blockquote
local Goal = {Position = reward2.Base.Position + Vector3.new(Chest.Bottom.SwordThing1.CFrame.LookVector.X * 2,-0.5,Chest.Bottom.SwordThing1.CFrame.LookVector.Z * 4)

2 Likes

Thank you!!! You are a lifesaver!

1 Like

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