Needing help with tweening force

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()
1 Like

I think the first argument of :Create has to be an object instead an object’s property.

I mean you just can’t enter BodyForce.Force in the first argument.

In the editor it underlines it with red and says “unknown global”

I personally think that means the script can not find the object.

So what should i do? create a int value or something?

Nah, it just maybe you made a typo and made the script unable to find that object.

I dont think so, i checked that and everything is right

Is the Board Object always appears in the game?

yeah it spawns with the player

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

For me, this is a lot safer and easier to read.

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

Is the error message still appears in the output?

Theres no error message anymore but it just doesnt work, not even the numbervalue goes down

What is db? Does it stands for ButtonDown? I’m not sure that if not db then is going to do the same thing as if db == false

And I suggest you to use a full name or you might not be able to remember what it stands for.

stands for de bounce cause i noticed that it was going up more than once

Have you check that bodyMover Object? Is it’s force changing?

No nothing is happening to the force

Why do you need to create a NumberValue? You can just declare local velocity = 0. Is there another script to read this value?