local tool = script.Parent local handle = tool.Handle local debounce = false tool.Activated:Connect(function() if not debounce then local plr = game.Players.LocalPlayer local body = plr.Character:GetDescendants() debounce = true plr.Character.Shirt:Destroy() plr.Character.Pants:Destroy() for _,v in pairs(body) do if v:IsA("BasePart") then v.BrickColor = BrickColor.new("Gold") v.Material = "Ice" end if v.Name == "Head" then v.Mesh:Destroy() end if v:IsA("Accessory") then v:Destroy() end end end wait(1) local bp = Instance.new("BodyPosition") bp.Parent = handle handle.Parent = game.Workspace bp.Position = Vector3.new(handle.Position.X,handle.Position.Y + 50,handle.Position.Z) local ts = game:GetService("TweenService") local info = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,true) local goal = {} goal.CFrame = goal.CFrame * CFrame.Angles(math.rad(1),math.rad(1),math.rad(1)) local tween = ts:Create(handle,info,goal) tween:Play() wait(5) handle:Destroy() print("yes") end)
Here is my full code, the part that is spitting out an error is
local goal = {} goal.CFrame = goal.CFrame * CFrame.Angles(math.rad(1),math.rad(1),math.rad(1))
Either I didn't learn tweenservice right, cause tables can't have a CFrame value, or I'll need to use a different way to do this.
CFrame expected, got nil
.On the line:
goal.CFrame = goal.CFrame * CFrame.Angles(math.rad(1),math.rad(1),math.rad(1))
You try manipulating the Angles to a CFrame that doesn't exist. Either replace goal.CFrame
with a new CFrame.new()
or use the CFrame of handle
. The latter is what I assume to be what you're looking for.
local goal = {} goal.CFrame = handle.CFrame * CFrame.Angles(math.rad(1),math.rad(1),math.rad(1))
Take note that the above doesn't really affect the angle of handle much.
Edit:
You could also use the Completed
event of the Tween
instance you play so you could destroy it. Better than using a wait()
So at the bottom of the code:
local goal = {} goal.CFrame = handle.CFrame * CFrame.Angles(math.rad(1),math.rad(1),math.rad(1)) local tween = ts:Create(handle,info,goal) tween:Play() tween.Completed:Wait() handle:Destroy() -->This is questionable though. Why not destroy tool? print("yes")
The idea of providing a table to a TweenService is that you can tween multiple values (CFrame, Color, Size, Transparency...) at the same time. So you are expected to provide a table of goal values, even if it is only one value you are tweening.
Replace :
local goal = {} goal.CFrame = goal.CFrame * CFrame.Angles(math.rad(1),math.rad(1),math.rad(1))
With:
local goal = {CFrame = handle.CFrame * CFrame.Angles(math.rad(1),math.rad(1),math.rad(1))}
As XPolarium explained, you would not probably notice such small angles anyway...