ApplyImpulse 10x more powerful on server/other clients

Hello, I am trying to make ball physics for my volleyball game following this tutorial, and the ball is just fine on the client of the player that hits the ball, but when it is updated to the server and other clients, the other clients see a ball that is shot up 10x higher. Here is a snippet from the module, server script, and local script:

--Local script
local con
			con =game:GetService("RunService").Heartbeat:Connect(function()
				if (balldetected == true and updated == true) or bumphb.Parent == nil then
					con:Disconnect()
				end
				for i,v in pairs(workspace:GetPartsInPart(bumphb, olp)) do
						
						
					if v.Name == 'ServerBall'  and v:GetAttribute("Active") then
						balldetected = true
							BumpInfo.DB = true
							v.GameBall:SetAttribute("Update",  false)
							if v:GetAttribute("Pwr") then
						if v:GetAttribute("Pwr") > 12  then
						--v.GameBall.Position = char.HumanoidRootPart.Position 
						end
							end
						local position = v:WaitForChild("GameBall").Position
						local force = ballmod.Bump(char, v.GameBall)
						packets.Bump.send({
							ball = v,
							pos = position,
							vel =force
						})

					
					
						local t = 0.1
						local tweeni = TweenInfo.new(t, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false)
						local goal = {Position = v.Position}
						local tween = ts:Create(v.GameBall, tweeni, goal)
					--	tween:Play()
						v:WaitForChild("GameBall"):SetAttribute("Update", true)
						updated = true
						
					end
				end
			end)
--Recieving from server (Local Script)
packets.Bump.listen(function(data)

	if data.ball.GameBall then

		data.ball.GameBall:ApplyImpulse(data.vel)
		data.ball.GameBall.Position = data.pos
	end
end)

Server script

packets.Bump.listen(function(data, player)

	--ball.ball.Position = ball.ball:WaitForChild("GameBall").Position
	--ballmod.Bump(player.Character, data["ball"])
	data.ball.Position = data.pos
	data.ball:ApplyImpulse(data.vel)
	data.ball:SetAttribute("Pwr", 0)
	task.spawn(function()
		data.ball:SetAttribute("JustHit", true)
		task.wait(0.2)
		data.ball:SetAttribute("JustHit", false)
	end)
	packets.Bump.sendToAllExcept({
		ball = data.ball,
		pos = data.pos,
		vel = data.vel
	}, player)
end)

Module

function module.Bump(char,ball)
	if (not ball:GetAttribute("ServeBall")) or ( ball:GetAttribute("ServeBall") and ball:GetAttribute("Server") == char) then
	task.spawn(function()
		ball:SetAttribute("JustHit", true)
		task.wait(0.2)
			ball:SetAttribute("JustHit", false)
	end)
	
	ball:SetAttribute("Power", 0)
	ball:SetAttribute("LastHit", char.Name)
	if ball:GetAttribute("Pwr") then
	if ball:GetAttribute("Pwr") > 11 then
	ball.Anchored = true
	ball.Anchored = false
				ball.AssemblyLinearVelocity = Vector3.new(0,0,0)
	end
	end
	local yoff 
	local xoff
	if char:GetAttribute("Pwr") > 11 then
		yoff = char:GetAttribute("Pwr")/4
	elseif char:GetAttribute("Pwr") < 5 then
			yoff = char:GetAttribute("Pwr") * 2
	else
			yoff = char:GetAttribute("Pwr")
	end
		if char:GetAttribute("Pwr") > 11 then
			xoff = char:GetAttribute("Pwr")/8
		elseif char:GetAttribute("Pwr") < 5 then
			xoff = char:GetAttribute("Pwr") 
		else
			xoff = char:GetAttribute("Pwr")
		end

		local pos1 = char.HumanoidRootPart.Position
	
		local pos2 =(char.HumanoidRootPart.CFrame+char.HumanoidRootPart.CFrame.LookVector * 40 ).p
		local dir = pos2 - pos1
		local dur = 3
		local force = dir/dur + Vector3.new(0, workspace.Gravity*dur/4, 0) 
		
		ball:ApplyImpulse(force * ball.AssemblyMass)
		return force * ball.AssemblyMass
	end 
end

By the way, I am using bytenet for communication between client and server (at least for this feature)

I just realized that the server ball is just fine, so its a problem with the receiving clients

Nevermind i found the solution, the events coupled with the heartbeat loop made it fire way too many times

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