Hi. I'm creating a simple gun in FilteringEnabled using a RemoteEvent. The gun has a local script, and there is a script in ServerScriptService. The local script has a function that runs when the tool is activated, which runs :FireServer() with all the correct arguments. Everything works fine in Play Mode, but when I run a server, the bullet just falls through the floor disappointingly.
Here's the script in ServerScriptService:
local gunre = game.ReplicatedStorage.RemoteEvents:WaitForChild("GunFire")
gunre.OnServerEvent:connect(function(player, part, mouse, damage)
local bullet = Instance.new("Part", part.Parent)
bullet.Name = "Bullet"
bullet.Size = Vector3.new(3,3,3)
bullet.BrickColor = BrickColor.new("New Yeller")
bullet.CanCollide = false
bullet.Anchored = false
bullet.CFrame = part.CFrame
bullet.CFrame = CFrame.new(bullet.Position, mouse.Hit.p)
game.Debris:AddItem(bullet, 2)
local vel = Instance.new("BodyVelocity", bullet)
vel.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
vel.Velocity = bullet.CFrame.lookVector * 800
bullet.Touched:connect(function(part)
local hum = part.Parent:findFirstChild("Humanoid")
if hum and hum.Health > 0 and part.Parent ~= player.Character then
hum.Health = hum.Health - damage
bullet:Destroy()
end
end)
end)
The Part/Bullet instance is created, but I looked and only found that the BodyVelocity wasn't even created. There's no errors, it's just not making a new instance for BodyVelocity at all. Any help is appreciated.
Thanks :} ~Loughdough
