When this was local it didn’t have that 1 second delay when you throw the part, but i changed the localscript into a server script, and now It just lags like .50s every throw
for short, this didn’t have a delay when it was a localscript:
ServerScript:
function HandleRockThrow(plr, direction)
local Monster = game:GetService("Workspace"):FindFirstChild("Monster")
local location = Vector3.new(0, 0, 0)
local Clone = game.ReplicatedStorage.Pebble:Clone()
Clone.Parent = workspace
Clone:SetNetworkOwnershipAuto()
Clone:PivotTo(plr.Character.HumanoidRootPart.CFrame * CFrame.new(0, 1, 0))
local forceMultipliter = 100 * Clone:GetMass()
Clone:ApplyImpulse(direction * forceMultipliter)
Clone.Touched:Connect(function(touched)
if touched.Parent ~= plr.Character and Clone:FindFirstChild("pebble") and Clone.touched.Value == false then
Clone.touched.Value = true
print(touched.Name)
Clone.pebble:Play()
local hitVisible = Instance.new("Part")
hitVisible.Size = Vector3.new(0.1, 0.1, 0.1)
hitVisible.Anchored = true
hitVisible.CanCollide = false
hitVisible.BrickColor = BrickColor.new("Lime green")
hitVisible.Parent = workspace
hitVisible.Position = Clone.Position
hitVisible.Material = Enum.Material.Neon
location = Clone.Position
end
end)
Localscript:
local direction = game.Players.LocalPlayer:GetMouse().Hit.LookVector
local RockEvent = Events.HandleRockThrow:InvokeServer(direction)