Im trying to use a tween on a force to make it slowly get slower but im getting an error that says “Unable to cast value to Object” when i run the script
local tInfo = TweenInfo.new(5,Enum.EasingStyle.Linear)
local tween = game:GetService("TweenService"):Create(Board.pushForce.Force,tInfo,{Z = 0})
tween:Play()
Oh, I guess you tried to ask the script to find the object before the player spawns. So that the script can’t find it. You will have to wait the player spawns before you tell the script to find that object.
Its in a localscript in the board so idk :\ ive tried doing the number stuff like this:
local velocity = Instance.new("NumberValue", LocalPlayer)
velocity.Name = "Velocity"
local function Push()
velocity = velocity + 1
end
pushForce.Force.Z = velocity.Value * 1500
local tInfo = TweenInfo.new(10,Enum.EasingStyle.Linear)
local tween = game:GetService("TweenService"):Create(velocity,tInfo,{Value = 0})
tween:Play()
but it gives me an error: “Z cannot be assigned to”
i dont know what to substitute it with because if i use a vector3 i dont know how to instead of just assign value like for example if i did
pushForce.Force = Vector3.new(0 , 0 ,0)
i want to be able to just add on top of the already present value :\
I personally don’t code a tween in 2 lines.
This is what I usually do:
local Service = game:GetService("TweenService")
local BodyMover = Board.pushForce
local Info = TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut)
local Goal = {}
Goal.Force = Vector3.new(0,0,Z)
local Tween = TweenService:Create(BodyMover,Info,Goal)
Tween:Play()
Thanks for the suggestion just right now im focusing on making the thing work
ive tried doing this but it just isnt working
local velocity = Instance.new("NumberValue", LocalPlayer)
velocity.Name = "Velocity"
db = false
local function Push()
if not db then
velocity.Value = velocity.Value + 1
db = true
wait(.2)
db = false
end
end
local Bruh = velocity.Value * 1500
pushForce.Force = Vector3.new(0, 0, Bruh )
local tInfo = TweenInfo.new(10,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut)
local tween = game:GetService("TweenService"):Create(velocity,tInfo,{Value = 0})
tween:Play()