R6 script not working in R15

I have a script that functions properly in R6, but in R15 the script doesn’t function. The function of the script is to swing a tool model across and bring it back.

local throw = function()
		local origin = hitbox.CFrame*CFrame.new(0,-hitbox.Size.Y/2,0)
		local top = hitbox.CFrame*CFrame.new(0,hitbox.Size.Y/2,0)
		local direction = (top.p-origin.p).unit
		local part,pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(origin.p,direction),{char,workspace.Storage})
		
		if part and part.Parent and part.Parent.Parent then 
			local hum = part.Parent:FindFirstChild('Humanoid') or part.Parent.Parent:FindFirstChild('Humanoid')
			if hum and not damagedb then
				damagedb = true
				hitSound:Play()
				damageEvent:FireServer(hum,100)
				wait(.4)
				damagedb = false
			end
		end
	end

What would I change to make this work in R15?

Not entirely sure where its not allowing it to work for R15 but I did notice a flaw in your code you might want to look into changing.

If I am reading this right, you are having the client tell the server to damage a humanoid, with:

damageEvent:FireServer(hum,100) 

You are essentially ‘trusting’ the client to send the correct humanoid with the correct damage, at the correct time. But exploiters can modify this. They can make it send any humanoid, with any damage, at any time. They can do this:

for k,v in pairs(game.Players:GetPlayers()) do 
	damageEvent:FireServer(v.Character.Humanoid,math.huge)
end

which will effectively loop kill all the players in the server no matter what their hp is at.

Instead I suggest you simply send the name of the player that should be damaged, and then let the server determine if its within proximity (and other checks) to then damage the player with the set damage value (again, determined by the server.) Hope this helps!

1 Like

Thank you for that additional suggestion! I will definitely consider doing that.

Update: Changing the origin, top, or direction doesn’t help out!

Solved: Not a scripting problem, it’s an issue with the animations since the tool was welded to the animation.