So, i basically want to get curret mouse position from server to make hitboxes for my punches ability.
This is the server script
local remote = script.Parent:WaitForChild("RemoteEvent")
local TweenService = game:GetService("TweenService")
local cooldown = false
local rand = math.random
remote.OnServerEvent:Connect(function(player)
if cooldown then return end
cooldown = true
local HumanoidRoot = player.Character:FindFirstChild("HumanoidRootPart")
task.spawn(function()
for i = 0, 300 do
game.ReplicatedStorage.circle:FireAllClients(HumanoidRoot, math.random(0, 1000))
task.wait(.1)
end
end)
task.wait(1)
cooldown = false
end)
and this is local one
local TweenService = game:GetService("TweenService")
local Sound = game:GetService("SoundService")
local circle = game.ReplicatedStorage.circle
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local BlockSize = 2
local GoldenRatio = 1 + math.sqrt(5) / 4
local AngleIncr = math.pi * 2 * GoldenRatio
local Multipler = BlockSize * 10
local MaxPoints = 1000
local CamShaker = require(game.ReplicatedStorage.CameraShaker)
local NewCam = CamShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
camera.CFrame = camera.CFrame * shakeCFrame
end)
circle.OnClientEvent:Connect(function(HumanoidRoot, i)
local Player = game.Players:GetPlayerFromCharacter(HumanoidRoot.Parent)
local Mouse = Player:GetMouse()
local MouseHit = Mouse.Hit
local NewPart = Instance.new("Part")
NewPart.Parent = workspace
NewPart.Anchored = true
NewPart.CanCollide = false
NewPart.Size = Vector3.new(BlockSize, BlockSize, 1)
local ChosenPoint = i --rand(1, MaxPoints)
local Distance = ChosenPoint / MaxPoints
local Angle = AngleIncr * ChosenPoint
local Incline = math.acos(1 - 2 * Distance)
local Azimuth = AngleIncr * ChosenPoint
local x = HumanoidRoot.Position.X + math.sin(Incline) * math.cos(Azimuth) * Multipler
local y = HumanoidRoot.Position.Y + math.sin(Incline) * math.sin(Azimuth) * Multipler
local z = HumanoidRoot.Position.Z + math.cos(Incline) * Multipler
local RandomPos = Vector3.new(x, y, z)
NewPart.CFrame = CFrame.new(RandomPos, MouseHit.Position)
local MouseMag = (MouseHit.Position - RandomPos).Magnitude
--if MouseMag > 500 then return end
local Tween = TweenService:Create(NewPart, TweenInfo.new(.8, Enum.EasingStyle.Quint, Enum.EasingDirection.In), {
Size = Vector3.new(BlockSize, BlockSize, MouseMag),
CFrame = NewPart.CFrame * CFrame.new(0, 0, -MouseMag / 2)
})
local TheOtherTween = TweenService:Create(NewPart, TweenInfo.new(.9, Enum.EasingStyle.Quint), {Transparency = 1})
Tween:Play()
task.delay(3, function()
TheOtherTween:Play()
task.wait(1.2)
NewPart:Destroy()
end)
Tween.Completed:Connect(function()
local PlayerItselfChar = player.Character
local Root = PlayerItselfChar:FindFirstChild("HumanoidRootPart")
local Mag = (Root.Position - MouseHit.Position).Magnitude
if Mag < 255 then
NewCam:Start()
NewCam:ShakeOnce(2, 10, 0, 3.2)
Sound:PlayLocalSound(script["20mm Rifle Shot"])
end
end)
end)
task.wait(6)
require(game.ReplicatedStorage.Paranoia).Inject()
im making the tweens and parts at the clientside so the player doesnt lag