I'm making a game where the movement relies on you shooting the opposite direction of where you want to propel yourself to. Right now, the problem i'm encountering is that after shoting, the pistol immediately drops down by gravity. i tried using massless but it seems like it's still affected by gravity.
(You may also give ideas for other parts of the script)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local shootEvent = ReplicatedStorage:FindFirstChild("ShootEvent")
local masslessDuration = 2
local activeTimers = {}
shootEvent.OnServerEvent:Connect(function(player)
local character = player.Character
if character then
local pistol = character:FindFirstChild("PistolModel") or character.PrimaryPart
if pistol then
print("Pistol Found, Applying Coordinate-Based Recoil!")
pistol.Massless = true
pistol.CFrame = pistol.CFrame * CFrame.new(-15, 0, 0)
if activeTimers[player] then
activeTimers[player]:Cancel()
end
activeTimers[player] = task.delay(masslessDuration, function()
if pistol then
pistol.Massless = false
activeTimers[player] = nil
print("Gravity restored for", player.Name)
end
end)
else
warn("PistolModel NOT found in character!")
end
else
warn("Character not found!")
end
end)
** You are now Level 7! **