I want to create a saber throw ability for the Temple Guards in my game. The issue is, I want the saber to rotate while being thrown. But I’m tweening the CFrame of the saber’s primary part to move the saber so it isn’t rotating despite the rotate part in my script.
Script for help trouble shooting:
game.ReplicatedStorage.SaberThrow.OnServerEvent:Connect(function(Player)
local TweenService = game:GetService("TweenService")
local TweenInformation = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0,
true,
0
)
local Saber = Player.Backpack:FindFirstChild("Double Bladed Yellow Saber") or Player.Character:FindFirstChild("Double Bladed Yellow Saber")
Player.Character.Humanoid:EquipTool(Saber)
for i, v in pairs(Saber:GetChildren()) do
if v:IsA("BasePart") then
v.Transparency = 1
end
end
local FakeSaber = game.ReplicatedStorage.Saber:Clone()
spawn(function()
while true do
if FakeSaber ~= nil then
wait(0.01)
FakeSaber.Body.CFrame = FakeSaber.Body.CFrame * CFrame.Angles(0, math.rad(10), 0)
else
break
end
end
end)
FakeSaber.Parent = workspace
FakeSaber:SetPrimaryPartCFrame(Player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-3))
TweenService:Create(FakeSaber.Body, TweenInformation, {CFrame = (Player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-20))}):Play()
wait(1)
TweenService:Create(FakeSaber.Body, TweenInformation, {CFrame = (Player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-2))}):Play()
wait(1)
FakeSaber:Destroy()
for i, v in pairs(Saber:GetChildren()) do
if v:IsA("BasePart") then
v.Transparency = 0
end
end
end)
Video for more help Trouble shooting:
Disclaimer:
The spawn function line I put is just something i’ll use until i fix the issue, then i’ll switch and replace it with a coroutine since it’s bad practice to use spawn. Another thing is, despite all the ways I attempted to word my searches, I could not find an answer.
I hope you guys can help me!