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)
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
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.
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()