"Unable to cast Vector3 to float" error while trying to replicate a R6 Torso bending script

Hello there!

I’m currently using a script from @amadeupworld2 to bend the players torso for a FPS game I’m currently working on. Although there is an issue in the tiltFunc function where it just randomly spews out “Unable to cast Vector3 to float” errors. Why is that?

local states = {
	[Enum.HumanoidStateType.Climbing] = true,
	[Enum.HumanoidStateType.Swimming] = true
}
local springs = {}
local cleanup = {}
local springsModule = require(script.Parent.spring)

script.Parent.TiltAt.OnServerEvent:Connect(function(player, theta)
	if (springs[player]) then
		springs[player].tilt.target = theta
	end
end)

script.Parent.SetUp.OnServerEvent:Connect(function(player)
	local tilt = springsModule.create(0,0,0,10,1)
	springs[player] = {}
	springs[player].tilt = tilt

	local character = player.Character;
	local humanoid = character:WaitForChild("Humanoid")

	local torso = player.Character:WaitForChild("Torso")
	local hrp = player.Character:WaitForChild("HumanoidRootPart")

	local neck = torso:WaitForChild("Neck")
	local root = hrp:WaitForChild("RootJoint")
	local rShoulder = torso:WaitForChild("Right Shoulder")
	local lShoulder = torso:WaitForChild("Left Shoulder")
	local rHip = torso:WaitForChild("Right Hip")
	local lHip = torso:WaitForChild("Left Hip")

	local neckC0 = neck.C0;
	local rootC0 = root.C0;
	local rShoulderC0 = rShoulder.C0;
	local lShoulderC0 = lShoulder.C0;
	local rHipC0 = rHip.C0;
	local lHipC0 = lHip.C0;

	local function tiltFunc(theta)
		neck.C0 = neckC0 * CFrame.fromEulerAnglesYXZ(-theta, 0, 0)
		root.C0 = rootC0 * CFrame.new(0, 0, -1) * CFrame.fromEulerAnglesYXZ(-theta, 0, 0) * CFrame.new(0, 0, 1)
		rShoulder.C0 = rShoulderC0 * CFrame.fromEulerAnglesYXZ(0, 0, theta)
		lShoulder.C0 = lShoulderC0 * CFrame.fromEulerAnglesYXZ(0, 0, -theta)
		rHip.C0 = rHipC0 * CFrame.fromEulerAnglesYXZ(0, 0, -theta)
		lHip.C0 = lHipC0 * CFrame.fromEulerAnglesYXZ(0, 0, theta)
	end

	local heartBeat = game:GetService("RunService").Heartbeat:Connect(function(dt)
		tilt:update(dt);
		tiltFunc(states[humanoid:GetState()] and 0 or tilt.Position / 2);
	end)
end)

The tilt.Position / 2 gives a vector value for theta.

Ah, alright then. I actually realize this script isn’t necessarily finished as it doesn’t constantly bend the player’s torso towards the mouse. But I guess that’s alright.

Oh and by the way, what’s a good FPS tutorial I can follow? Just asking for a friend.

Unsure, I don’t work with first person shooters.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.