Can you modify this brick throwing system to make it so it doesn't ever cause 100 damage…
- User
Can you modify this brick throwing system to make it so it doesn't ever cause 100 damage unless the player holds a fully charged brick for 3 seconds?
Like, when they first charge a brick up, it doesn't start a countdown, but then when the chargetime reaches it's maximum, it only causes a maximum of 90 damage, but, if the player continues holding a maxcharged charged brick for 3 seconds, then a function is called on the client and server, and when they throw it, then the brick always does 120 damage.
Here are the scripts:
Client:
task.wait(1) local plr = game.Players.LocalPlayer local humanoid = plr.Character:WaitForChild("Humanoid", 6) local mouse = plr:GetMouse() local camera = game.Workspace.CurrentCamera local RS = game:GetService("ReplicatedStorage") local stats = RS:WaitForChild("Statistics"):WaitForChild("GetPlayerStats"):InvokeServer() local ThrowEvent = RS:WaitForChild("Throw") local HighJump = RS:WaitForChild("HighJump") local Land = RS:WaitForChild("Land") local UIS = game:GetService("UserInputService") local runService = game:GetService("RunService") local gravityForce local success, result = pcall(function() gravityForce = Vector3.new(0, game.Workspace.Gravity * plr.Character.HumanoidRootPart.AssemblyMass * stats.powerjumpgravity or 0.95, 0) end) if result then warn(result) end local walkspeed = humanoid.WalkSpeed local jumppower = humanoid.JumpPower local bodyForce local debounce = false local charging = false local trajectoryUpdateConnection local trajectoryParts = {} local maxChargeTime = 3 local maxParts = 40 local lastMousePos local lastRootPos local ChargeModule = require(RS.GameModules:WaitForChild("Charging")) local ChargeTimeValue = RS:WaitForChild("ChargeTime") local chargeAnimation = script:WaitForChild("Charge") local throwAnimation = script:WaitForChild("Throw") local flythrowAnimation = script:WaitForChild("FlyingThrow") local grabAnimation = script:WaitForChild("Grab") local ascendAnimation = script:WaitForChild("Ascend") local landingAnimation = script:WaitForChild("Landing") local ascendAnimTrack = humanoid:LoadAnimation(ascendAnimation) local landingAnimTrack = humanoid:LoadAnimation(landingAnimation) local chargeAnimTrack = humanoid:LoadAnimation(chargeAnimation) local throwAnimTrack = humanoid:LoadAnimation(throwAnimation) local flythrowAnimTrack = humanoid:LoadAnimation(flythrowAnimation) local grabAnimTrack = humanoid:LoadAnimation(grabAnimation) chargeAnimTrack.Looped = true local chargeSpeed = 1 local throwcooldown = 1.25 local success, result = pcall(function() chargeSpeed = stats.chargeSpeed or 1 throwcooldown = stats.throwCooldown or 1.25 end) if result then warn(result) end local function calculateTrajectory(startPos, direction, chargeTime) local trajectory = {} local velocity = direction.unit * (math.min(chargeTime, maxChargeTime) * 50) local gravity = Vector3.new(0, -24, 0) local timeStep = 0.1 for i = 1, maxParts do local time = i * timeStep local position = startPos + velocity * time + gravity * (time^2 / 2) table.insert(trajectory, position) end return trajectory end local function rotate() local rootPart = plr.Character:FindFirstChild("HumanoidRootPart") if rootPart and charging then local lookAt = CFrame.lookAt(rootPart.Position, mouse.Hit.p) rootPart.CFrame = rootPart.CFrame:Lerp(lookAt, 0.075) end end local folderstorage = Instance.new("Folder") folderstorage.Name = "Storage" folderstorage.Parent = workspace local function createTrajectoryParts() local parts = {} for i = 1, maxParts do local part = Instance.new("Part") part.Size = Vector3.new(0.2, 0.2, 0.2) part.Anchored = true part.CanCollide = false part.Material = Enum.Material.Neon part.Parent = folderstorage table.insert(parts, part) end return parts end local function handleLanding(velocity) print(velocity) debounce = true local rootPart = plr.Character:FindFirstChild("HumanoidRootPart") task.delay(.15, function() rootPart.Anchored = true end) landingAnimTrack:Play() local function onLanding() local rocksmodule = require(RS:WaitForChild("GameModules"):WaitForChild("RocksModule")) local fallSpeed = math.abs(velocity) local rockDistance = 3.5 * (fallSpeed / 100) rocksmodule.Ground(plr.Character:WaitForChild("HumanoidRootPart").Position - Vector3.new(0, 2, 0), rockDistance, Vector3.new(3, 0.75, 3), nil, rockDistance*2, false, 4.5, 2) Land:FireServer("Hard", velocity) end task.spawn(onLanding) landingAnimTrack.Stopped:Connect(function() rootPart.Anchored = false debounce = false end) end local function updateTrajectoryParts(parts, trajectory, chargeTime) local colorStart = Color3.fromRGB(90, 90, 255) local colorEnd = Color3.fromRGB(255, 53, 56) local chargePercent = math.min(chargeTime / maxChargeTime, 1) local trajectoryLength = #trajectory for i, part in ipairs(parts) do if i > trajectoryLength then part.Transparency = 1 else local partColor = colorStart:lerp(colorEnd, chargePercent) part.Color = partColor if i == 1 then local currentPos = trajectory[i] local rootPos = plr.Character["HumanoidRootPart"].Position local midPoint = (rootPos + currentPos) / 2 local size = (rootPos - currentPos).Magnitude part.Size = Vector3.new(0.1, 0.1, size) part.CFrame = CFrame.new(midPoint, currentPos) else local previousPartPos = trajectory[i-1] local currentPos = trajectory[i] local midPoint = (previousPartPos + currentPos) / 2 local size = (previousPartPos - currentPos).Magnitude part.Size = Vector3.new(0.1, 0.1, size) part.CFrame = CFrame.new(midPoint, currentPos) end end end end local function throwBrick(chargeTime) charging = false debounce = true ThrowEvent:FireServer(mouse.Hit.p, math.min(chargeTime, maxChargeTime), throwcooldown) if humanoid.FloorMaterial ~= Enum.Material.Air then throwAnimTrack:Play() throwAnimTrack:AdjustSpeed(throwAnimTrack.Length / throwcooldown * 2) else flythrowAnimTrack:Play() flythrowAnimTrack:AdjustSpeed(flythrowAnimTrack.Length / throwcooldown * 2) end chargeAnimTrack:Stop() ascendAnimTrack:Stop() end local function cancel() if charging then charging = false ChargeModule.StopCharge() humanoid.WalkSpeed = walkspeed humanoid.JumpPower = jumppower if bodyForce then bodyForce:Destroy() end chargeAnimTrack:Stop() if trajectoryUpdateConnection then trajectoryUpdateConnection:Disconnect() end for _, part in ipairs(folderstorage:GetChildren()) do part:Destroy() end trajectoryParts = {} debounce = false end end humanoid.StateChanged:Connect(function(oldState, newState) local success, result = pcall(function() if newState == Enum.HumanoidStateType.Landed and oldState == Enum.HumanoidStateType.Freefall then local verticalVelocity = plr.Character.HumanoidRootPart.AssemblyLinearVelocity.Y if verticalVelocity < -110 then handleLanding(verticalVelocity) else Land:FireServer("Soft") end end end) if result then warn(result) end end) UIS.InputBegan:Connect(function(input) local success, result = pcall(function() if plr.Character:FindFirstChild("BrickDisabled").Value == true then return end local ragdollTrigger = plr.Character:FindFirstChild("SetRagdoll") local abilityactive = plr.Character:FindFirstChild("AbilityActive") if input.UserInputType == Enum.UserInputType.MouseButton1 then if not debounce and not charging and not ragdollTrigger.Value and not abilityactive.Value then local verticalVelocity = plr.Character.HumanoidRootPart.AssemblyLinearVelocity.Y if verticalVelocity > 35 then task.spawn(function() ChargeModule.SetChargeSpeed(0.75) local duration = 0.5 local steps = 10 for i = 1, steps do local alpha = i / steps local speed = 2 - (alpha * (2 - 1)) ChargeModule.SetChargeSpeed(speed) task.wait(duration / steps) end ChargeModule.SetChargeSpeed(1) end) HighJump:FireServer(plr.Character) ascendAnimTrack:Play() end charging = true ChargeModule.StartCharge(chargeSpeed, maxChargeTime) trajectoryParts = createTrajectoryParts() chargeAnimTrack:Play(0.5) humanoid.WalkSpeed = walkspeed/2 humanoid.JumpPower = 0 bodyForce = Instance.new("BodyForce") bodyForce.Force = Vector3.new(0, 0, 0) bodyForce.Parent = plr.Character.HumanoidRootPart local initialAntiGravityFactor = verticalVelocity > 35 and 0.95 or 0.6 trajectoryUpdateConnection = runService.RenderStepped:Connect(function() if ragdollTrigger.Value or abilityactive.Value then cancel() else local currentMousePos = mouse.Hit.p local currentRootPos = plr.Character.HumanoidRootPart.Position if lastMousePos ~= currentMousePos or lastRootPos ~= currentRootPos then lastMousePos = currentMousePos lastRootPos = currentRootPos local chargeTime = ChargeTimeValue.Value local direction = (mouse.Hit.p - plr.Character.HumanoidRootPart.Position).unit local startPos = plr.Character["HumanoidRootPart"].Position local trajectory = calculateTrajectory(startPos, direction, chargeTime) updateTrajectoryParts(trajectoryParts, trajectory, chargeTime) local speed = math.min(chargeTime / maxChargeTime, 3) chargeAnimTrack:AdjustSpeed(speed) rotate() local antiGravityFactor = math.max(1 - chargeTime / maxChargeTime, 0) bodyForce.Force = gravityForce * antiGravityFactor * initialAntiGravityFactor end end end) end elseif input.KeyCode == Enum.KeyCode.X then cancel() elseif input.KeyCode == Enum.KeyCode.R and charging then ChargeModule.PauseCharge() end end) if result then warn(result) end end) UIS.InputEnded:Connect(function(input) local success, result = pcall(function() if plr.Character:FindFirstChild("BrickDisabled").Value == true then return end if input.UserInputType == Enum.UserInputType.MouseButton1 then if bodyForce then bodyForce:Destroy() end if charging and not debounce then ChargeModule.StopCharge() charging = false humanoid.WalkSpeed = walkspeed humanoid.JumpPower = jumppower plr.Character:FindFirstChild("HumanoidRootPart").Anchored = false local chargeTime = ChargeTimeValue.Value for _, part in ipairs(folderstorage:GetChildren()) do part:Destroy() end trajectoryParts = {} throwBrick(chargeTime) if trajectoryUpdateConnection then trajectoryUpdateConnection:Disconnect() end task.spawn(function() local gui = plr.PlayerGui.Template local cooldownTime = throwcooldown debounce = true local startTime = tick() while cooldownTime > 0 do local elapsedTime = tick() - startTime cooldownTime = throwcooldown - elapsedTime gui.BrickCD.Text = string.format("%.1f", math.max(cooldownTime, 0)) task.wait(0.1) end end) task.delay(throwAnimTrack.Length / throwAnimTrack.Speed, function() grabAnimTrack:Play() grabAnimTrack:AdjustSpeed(grabAnimTrack.Length / throwcooldown * 2) task.wait(throwAnimTrack.Length / throwAnimTrack.Speed) debounce = false end) end elseif input.KeyCode == Enum.KeyCode.E and charging then ChargeModule.UnpauseCharge() end end) if result then warn(result) end end) - Assistant