Debris can't cast value to object

  1. What do you want to achieve? Fix the error I am receiving.

  2. What is the issue? Debris doesn’t eliminate body velocity however returns it is unable to cast the object

  3. What solutions have you tried so far? I have searched in the devforum about the error and nothing seems familiar to what is happening to me

local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DebrisService = game:GetService("Debris")

local SpiderFolder = ReplicatedStorage:WaitForChild("Advanced Spider")
local Event = SpiderFolder:WaitForChild("Base"):WaitForChild("Events"):WaitForChild("Web Yank")

Event.OnServerEvent:Connect(function(Player)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
	local Humanoid = Character:WaitForChild("Humanoid")

	local UsingMove = Character.UsingMove
	local Stunned = Character.Stunned
	local Blocking = Character.Blocking
	local Ragdolled = Character.Ragdolled

	if UsingMove.Value == true or Stunned.Value == true or Blocking.Value == true or Ragdolled.Value == true then return end
	UsingMove.Value = true
	
	local UpperCut = Humanoid.Animator:LoadAnimation(script.Uppercut)
	UpperCut:Play()
	
	local Part1 = Instance.new("Part")
	Part1.Parent = workspace
	Part1.Name = "UpperCutHitbox"
	Part1.Anchored = false
	Part1.CanCollide = false
	Part1.Size = Vector3.new(9, 5.5, 9)
	Part1.CFrame = HumanoidRootPart.CFrame + HumanoidRootPart.CFrame.LookVector * 3
	Part1.Transparency = .5
	
	local Weld = Instance.new("Weld")
	Weld.Parent = Part1
	Weld.Part0 = Part1
	Weld.Part1 = HumanoidRootPart
	
	local con 
	
	con = Part1.Touched:Connect(function(hit)
		local enemy = hit.Parent:FindFirstChild("Humanoid")
		if hit.Parent == Character then return end
		if enemy then
			con:Disconnect()
			enemy.Parent.Stunned.Value = true
			local UpVelocity = Instance.new("BodyVelocity", enemy.Parent.HumanoidRootPart)
			UpVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			UpVelocity = hit.Parent.HumanoidRootPart.CFrame.UpVector * 65
			game.Debris:AddItem(UpVelocity, .5)
		end
	end)
	
end)

The error says “Unable to cast value to Object” at game.Debris:AddItem(UpVelocity, .5)

2 Likes

Try game:GetService(“Debris”):AddItem(UpVelocity, .5)

1 Like

Same thing… It returns the same error.

Add a .Velocity after the Upvelocity above the debris line. Your setting the bodyvelocity to a vector3 rather than setting it’s actual velocity.

3 Likes

Thanks a lot! However, I’m having a slight problem on something. (I added this after posting this)

local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DebrisService = game:GetService("Debris")

local SpiderFolder = ReplicatedStorage:WaitForChild("Advanced Spider")
local Event = SpiderFolder:WaitForChild("Base"):WaitForChild("Events"):WaitForChild("Web Yank")

Event.OnServerEvent:Connect(function(Player)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
	local Humanoid = Character:WaitForChild("Humanoid")

	local UsingMove = Character.UsingMove
	local Stunned = Character.Stunned
	local Blocking = Character.Blocking
	local Ragdolled = Character.Ragdolled

	if UsingMove.Value == true or Stunned.Value == true or Blocking.Value == true or Ragdolled.Value == true then return end
	UsingMove.Value = true
	
	local UpperCut = Humanoid.Animator:LoadAnimation(script.Uppercut)
	UpperCut:Play()
	
	local Part1 = Instance.new("Part")
	Part1.Parent = workspace
	Part1.Name = "UpperCutHitbox"
	Part1.Anchored = false
	Part1.CanCollide = false
	Part1.Size = Vector3.new(9, 5.5, 9)
	Part1.CFrame = HumanoidRootPart.CFrame + HumanoidRootPart.CFrame.LookVector * 3
	Part1.Transparency = .5
	
	local Weld = Instance.new("Weld")
	Weld.Parent = Part1
	Weld.Part0 = Part1
	Weld.Part1 = HumanoidRootPart
	
	local con 
	
	con = Part1.Touched:Connect(function(hit)
		local enemy = hit.Parent:FindFirstChild("Humanoid")
		if hit.Parent == Character then return end
		if enemy then
			con:Disconnect()
			
			local Beam = SpiderFolder:WaitForChild("Base"):WaitForChild("Effects"):WaitForChild("Beam"):WaitForChild("Beam"):Clone()
			Beam.Parent = HumanoidRootPart
			if Beam then -- made for testing (since it was not working)
				Beam.Enabled = false
				Beam.Enabled = true
			end
			
			local One = SpiderFolder:WaitForChild("Base"):WaitForChild("Effects"):WaitForChild("Beam"):WaitForChild("One"):Clone()
			One.Parent = HumanoidRootPart		
			
			local Two = SpiderFolder:WaitForChild("Base"):WaitForChild("Effects"):WaitForChild("Beam"):WaitForChild("Two"):Clone()
			Two.Parent = enemy.Parent.HumanoidRootPart
			
			
			enemy.Parent.Stunned.Value = true
			local UpVelocity = Instance.new("BodyVelocity", hit.Parent.HumanoidRootPart)
			UpVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			UpVelocity.Velocity = hit.Parent.HumanoidRootPart.CFrame.UpVector * 35
			DebrisService:AddItem(UpVelocity, .5)
		end
	end)
	
end)

I don’t know if this is a problem or if I did this wrong but why is my beam not showing?

1 Like

Whats this line?

UpVelocity = hit.Parent.HumanoidRootPart.CFrame.UpVector * 65?

local UpVelocity = Instance.new("BodyVelocity", enemy.Parent.HumanoidRootPart)
UpVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
UpVelocity = hit.Parent.HumanoidRootPart.CFrame.UpVector * 65

It shouldnt be something like:
UpVelocity.Velocity = hit.Parent.HumanoidRootPart.CFrame.UpVector * 65

Or related?, your line makes no sense

1 Like

I forgot to add .Velocity, just fixed it!

1 Like

Are the attachment properties set?

1 Like

imagen_2023-10-30_175737950
Which of these you mean?