Ok, so I tried to make it on my own and, I’m having massive issues…
Issue 1 - Multiple bombs are created at a time
Issue 2 - The gravity is always high
The way I intended the system to work is, If the hold time was 1 - 5, then depending on least to greatest-ness of the number, the trajectory of the bomb will be increase or descreased, but the complete opposite happened and the script doesn’t even work. The remote event is fired multiple times for some reason, and I’m stuck on what to do.
local ActivationEvent = script.Parent:WaitForChild("ThrowBomb")
local tool = script.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)
local mouse = player:GetMouse()
tool.Activated:Connect(function()
local mousetime = 0
local fired = false
local function MouseButton1Down()
if not fired then
fired = true
repeat task.wait(.1)
mousetime += .1
until not mouse.Button1Up
else
return
end
end
local function MouseButton1Up()
mousetime = math.round(mousetime)
if mousetime <= 1 or mousetime == 1 then
ActivationEvent:FireServer(player, mouse.Hit, player.Character, 1)
elseif mousetime == 2 then
ActivationEvent:FireServer(player, mouse.Hit, player.Character, .8)
elseif mousetime == 3 then
ActivationEvent:FireServer(player, mouse.Hit, player.Character, .6)
elseif mousetime == 4 then
ActivationEvent:FireServer(player, mouse.Hit, player.Character, .4)
elseif mousetime == 5 then
ActivationEvent:FireServer(player, mouse.Hit, player.Character, .2)
end
end
mouse.Button1Up:Connect(MouseButton1Up)
mouse.Button1Down:Connect(MouseButton1Up)
end)
local ActivationEvent = script.Parent:WaitForChild("ThrowBomb")
local BombFuse = script.Parent:WaitForChild("Bomb Fuse")
local Explosion = script.Parent:WaitForChild("Explosion")
function calculateVelocity(startPos, endPos, mousetime)
local G = (endPos - startPos) + Vector3.new(0, workspace.Gravity * mousetime, 0)
return G
end
ActivationEvent.OnServerEvent:Connect(function(player, character, mouseHit, char, mousetime)
local Bomb = script.Parent:WaitForChild("Handle"):Clone()
Bomb.Parent = workspace:WaitForChild("ClonedBombs")
Bomb.Name = "clonedBomb"
Bomb.AssemblyLinearVelocity = calculateVelocity(Bomb.Position, mouseHit.Position, mousetime)
Bomb.CanCollide = true
end)
-- Bomb:ApplyImpulseAtPosition(mouseHit.p, Bomb.Position)