Gotta use Vector 3 values then, also if it’s a model then tween the primary part’s position.
the primary part is the tree.Tree
Gimme 15 minutes, I gotta walk home lol
got i :::::::::::::::::::::::::::::::::::::::::
You should tween CFrame instead of the Position and Orientation. For some reason, changing Position and Orientation directly doesn’t affect welded objects.
The problem is here,
local goal = {Orientation = Vector3.new(0,0,75), Position = script.Parent.Position + Vector3.new(0,-3,0)}
You have to tween the CFrame when you are tweening models
Angles = CFrame.angles()
, position = CFrame.new()
they function similarly to Vector.new()
so you won’t have to change much.
|
Also make sure you’re using math.rad(--your number)
when tweening the oriations
Example
local goal = {CFrame = CFrame.angles(0,0,math.rad(75))}
|
This post may also help
it givers an eror with attempt to call nil value whenI use the code though
what exactly are the code you’re using as of now?
Im using it to twewen a tree falling down
I mean the actual code, what code did you use just now that gave you the error
this gave the error
local goal = {CFrame = CFrame.angles(0,0,math.rad(75))}
local tweenlog = Tween:Create(tree.Tree,tweenInfo,goal)
Try using this function:
local function TreeFalls(tree, angle : number) -- should be the tree model
local TS = game:GetService("TweenService")
local tween_info = TweenInfo.new(2, Enum.EasingStyle.Bounce)
local tween = TS:Create(tree.PrimaryPart, tween_info, {
CFrame = tree.PrimaryPart * CFrame.angles(0,0,math.rad(angle)) + Vector3.new(0,-3,0)
})
tween:Play()
end
nothing happwens, i think i implemented it wrong
local handle = script.Parent
local Players = game:GetService("Players")
local goi = Players.LocalPlayer.PlayerGui.Gui
local Tween = game:GetService("TweenService")
local Replicatedstorage = game:GetService("ReplicatedStorage")
local Woodadd = Replicatedstorage.Wood
local woodPosition = UDim2.new(0.253, 0,-0.028, 0)
local tweenInfo = TweenInfo.new(2)
local leaderstats = Players.LocalPlayer:WaitForChild("leaderstats")
local wood = leaderstats.Wood
rotation = CFrame.Angles(0,0, math.rad(75))
local damage = 20
local canSwing = true
db = true
handle.Touched:Connect(function(hit)
if hit.Parent.Name == "Tree"and db == true and not canSwing then
local amount
if goi:FindFirstChildOfClass("IntValue") then -- since you parent your int value to the goi thing I checked that
else
amount = Instance.new("IntValue")
amount.Parent = goi
end
amount = goi:FindFirstChildOfClass("IntValue")
local tree = hit.Parent
local modelCFrame = tree:GetPivot()
local health = tree.Health
local DamageDelt = tree.DamageDelt
db = false
goi.CanvasGroup.Visible = true
health.Value -= damage
DamageDelt.Value += damage
amount.Value += 1
if health.Value == 0 or health.Value < 0 then
print(health.Value)
goi.CanvasGroup.Amount.Size = UDim2.new(DamageDelt.Value/100,0,0,75)
local random = math.random(1,90)
local xnew = random/100
local wood2 = game.ReplicatedStorage.Wood:Clone()
wood2.Parent = Players.LocalPlayer.PlayerGui.Items
wood2.Position = UDim2.new(xnew,0,0.76,0)
wood2.TextLabel.Text = "+1"
local tween = Tween:Create(wood2, tweenInfo, {Position = woodPosition})
tween:Play()
local function TreeFalls(tree, angle : number) -- should be the tree model
local tween_info = TweenInfo.new(2, Enum.EasingStyle.Bounce)
local tween = Tween:Create(tree.PrimaryPart, tween_info, {
CFrame = tree.PrimaryPart * CFrame.angles(0,0,math.rad(angle)) + Vector3.new(0,-3,0)
})
tween:Play()
end
goi.CanvasGroup.Visible = false
goi.CanvasGroup.Amount.Size = UDim2.new(0.2,0,0,75)
amount:Destroy()
task.wait(1.3)
wood.Value += 1
wood2:Destroy()
end
if health.Value <= 100 then
goi.CanvasGroup.Amount.Size = UDim2.new(DamageDelt.Value/100,0,0,75)
local random = math.random(1,90)
local xnew = random/100
local wood2 = game.ReplicatedStorage.Wood:Clone()
wood2.Parent = Players.LocalPlayer.PlayerGui.Items
wood2.Position = UDim2.new(xnew,0,0.76,0)
wood2.TextLabel.Text = "+1"
local tween = Tween:Create(wood2, tweenInfo, {Position = woodPosition})
tween:Play()
task.wait(1.3)
wood.Value += 1
wood2:Destroy()
end
task.wait(1)
db = true
else
print(hit.Parent.Name)
end
end)
handle.Parent.Activated:Connect(function()
if canSwing then
canSwing = false
task.wait(1)
canSwing = true
end
end)
Did you call the function? remember to pass the arguments
whoopsps :::::::::::::::::::::::::::::::::
Uh you are supposed to put it outside the connected function, and whenever you want the tween to play on the tree, you call it.
This was an example
local goal = {CFrame = CFrame.angles(0,0,math.rad(75))}
I also wasn’t in studio to test it, also you should of fixed it yourself. Well anyways, replace that with this
local goal = {CFrame = script.Parent.CFrame * (CFrame.new(0,-3,0) * CFrame.Angles(0,0,math.rad(75)))}
Sorry for the delayed response, had some problems when testing
it is saying invalid argument #1 to ‘rad’ (number expected, got nil)
Did you pass an angle to the function? It’s the second argument.