Baseplate is falling when hit at an angle?

Here is a video sorry i used the roblox studio recorder :woozy_face:
robloxapp-20231015-1349235.wmv (2.8 MB)
here is a video of the glitch in action using one of my melee weapons. I have a feeling this script below is the cause because when trying to perform this glitch using somthing from the toolbox it won’t work. I think that i am forgetting something but looking through everything looks right to me.

local Tool = script.Parent
Tool.Enabled = true

local Handle = Tool:WaitForChild("Handle")

local Sounds = {
	Hit = Handle:WaitForChild("Hit"),
	Swing = Handle:WaitForChild("Swing")
}

local Animations = {}

local Services = {
	Players = (game:FindService("Players") or game:GetService("Players")),
	Debris = (game:FindService("Debris") or game:GetService("Debris")),
}

local events = {}

local Player,Character,Humanoid


function IsTeamMate(Player1, Player2)
	return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
end

function TagHumanoid(humanoid, player)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.Value = player
	Services.Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

function UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			v:Destroy()
		end
	end
end

function IsInTable(Table,Value)
	for _,v in pairs(Table) do
		if v == Value then
			return true
		end
	end
	return false
end

local HitHumanoids = {}
function Activated()
	if not Tool.Enabled or not Humanoid or Humanoid.Health <= 0 then return end
	Tool.Enabled = false
	delay(0.8,function()
		HitHumanoids = {}
		Tool.Enabled = true
	end)
	Animations.ChopAnim:Play()
	Sounds.Swing:Play()
end

function Touched(hit)
	if not hit or not hit.Parent or Tool.Enabled then return end
	local hum,ff = hit.Parent:FindFirstChildOfClass("Humanoid"),hit.Parent:FindFirstChildOfClass("ForceField")
	if not hum or hum.Health <= 0 or ff or IsTeamMate(Services.Players:GetPlayerFromCharacter(hum.Parent),Player) or IsInTable(HitHumanoids,hum) then return end
	
	HitHumanoids[#HitHumanoids+1]=hum
	UntagHumanoid(hum)
	TagHumanoid(hum,Player)
	hum:TakeDamage(5)
	Sounds.Hit:Play()
	if not string.find(string.lower(hit.Name),"root") and ((string.find(string.lower(hit.Name),"torso") or string.find(string.lower(hit.Name),"head")) and Random.new():NextNumber(0,100) <= 50) or (not string.find(string.lower(hit.Name),"torso") and not string.find(string.lower(hit.Name),"head") and not string.find(string.lower(hit.Name),"root")) then
		hit.Anchored = false
		
		
	end

end

function Equipped()
	Character = Tool.Parent
	Player = Services.Players:GetPlayerFromCharacter(Character)
	Humanoid = Character:FindFirstChildOfClass("Humanoid")
	
	if not Humanoid or Humanoid.Health <= 0 then return end
	
	Animations = {
		ChopAnim = Humanoid:LoadAnimation(Tool:WaitForChild("Chop"..Humanoid.RigType.Name))
	}
	
	events[#events+1] = Tool.Activated:Connect(Activated)
	events[#events+1] = Handle.Touched:Connect(Touched)
end

function Unequipped()
	for i=1,#events do
		if events[i] then events[i]:Disconnect();events[i] = nil end
	end
end

Tool.Equipped:Connect(Equipped)

If anybody can solve this it would be wonderful as the my current solution to this glitch is to check to see if the baseplate has been destroyed and if so make a new one via replicated storage.

My guess is that your humanoid/forcefield check is the culprit because it’s allowing the baseplate to pass through the checks.

Let me show you what I think these lines are doing when your hammer hits the baseplate.

if not hit or not hit.Parent or Tool.Enabled then return end

local hum,ff = hit.Parent:FindFirstChildOfClass("Humanoid"),hit.Parent:FindFirstChildOfClass("ForceField")

if not hum or hum.Health <= 0 or ff or IsTeamMate(Services.Players:GetPlayerFromCharacter(hum.Parent),Player) or IsInTable(HitHumanoids,hum) then return end

...

Logic:

  1. Is Baseplate a hit? > it is, continue with script.
  2. Get the parent of the Baseplate (which is Workspace). Now check the whole workspace for a child which is a Humanoid or Forcefield. > Found a Humanoid or Forcefield, continue with script.
  3. If there was not a Humanoid or Forcefield then return. > There was a Humanoid or Forcefield so continue with the rest of the script.
    …
  4. Unanchor the hit (which is the Baseplate) > Done, baseplate falls.

Most likely you have a humanoid or forcefield somewhere in the workspace that the script is finding, allowing it to continue.

Solution

To solve this you could instead check if the hit is a player’s character and then find the Humanoid.

if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) then

Something like this would work for the player, but if you have an NPC or another object that you want to be hit (like the duck), it wouldn’t let you. One solution is using CollectionService’s tags.

For example you could add a tag to the duck named “CanHit” (by using the Tag Editor in studio or CollectionService:AddTag()). Then just check if the hit has the “CanHit” tag.

local CollectionService = game:GetService("CollectionService")

if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) or CollectionService:HasTag(hit, "CanHit") then
	local hum, ff = hit.Parent:FindFirstChildOfClass("Humanoid"), hit.Parent:FindFirstChildOfClass("ForceField")

	... -- Continue script
end

Again, this is just what I think it could be.

Edit: Now that I look at the script again it’s probably this if statement right before it unanchors the hit.

if not string.find(string.lower(hit.Name),"root") and ((string.find(string.lower(hit.Name),"torso") or string.find(string.lower(hit.Name),"head")) and Random.new():NextNumber(0,100) <= 50) or (not string.find(string.lower(hit.Name),"torso") and not string.find(string.lower(hit.Name),"head") and not string.find(string.lower(hit.Name),"root"))

More specifically near the end when you are checking if hit does not contain “head”, “torso” or “root”. However the solution I provided should deal with this issue indirectly.