So there two teams and a line which players arent able to cross and if they get to close then they get knocked back… this works but for some odd reason when a player does it other clients also apply the same effect… but this is completely client sided though…
Really not sure what’s going on
local lastFlungTime = 0
local function fling(team)
local bv = Instance.new("BodyVelocity")
bv.P = math.huge
bv.MaxForce = Vector3.new(100000,0,100000)
bv.Parent = root
if team == RedTeam then
bv.Velocity = (root.Position - Vector3.new(root.Position.X, root.Position.Y,root.Position.Z + RedLine.PivotOffset.Position.Z)).Unit * -60
else
bv.Velocity = (root.Position - Vector3.new(root.Position.X, root.Position.Y, root.Position.Z + BlueLine.PivotOffset.Position.Z)).Unit * -60
end
task.spawn(function()
local knockBacksound = Instance.new("Sound")
knockBacksound.Parent = character.PrimaryPart
knockBacksound.Volume = .55
knockBacksound.SoundId = "rbxassetid://122712887476025"
repeat task.wait() until knockBacksound.IsLoaded
knockBacksound:Play()
knockBacksound.Ended:Connect(function()
knockBacksound:Destroy()
end)
end)
CameraShakerUtility.camShake:Shake(CameraShaker.Presets.Explosion)
Debris:AddItem(bv, .1)
end
RedLine.Detector.Touched:Connect(function()
if workspace:GetServerTimeNow() - lastFlungTime > .7 then
fling(RedTeam)
end
lastFlungTime = workspace:GetServerTimeNow()
end)
BlueLine.Detector.Touched:Connect(function()
if workspace:GetServerTimeNow() - lastFlungTime > .7 then
fling(BlueTeam)
end
lastFlungTime = workspace:GetServerTimeNow()
end)