-
I want to make it so that the damage is set to 0 for about 2 seconds before changing to 45 dmg.
-
The issue is that a moving the player would run into the projectile as it is created using the position of the torso, damaging the player if and when moving forward.
-
I changed the part’s CFrame.new to 10, however i want it to be 2 where the gun is. (but currently if set to 2 the player is damaged.)
The projectile is created by a Local Script in the Starterpack that fires a script within that local script.
Within that local script is also a RemoteEvent, named “RemoteEvent”.
The game is an First Person Shooter, where there is a StarterCharacter with a gun model w/ Motor3d)
The Local Script:
local Event = script:WaitForChild(“RemoteEvent”)
local UIS = game:GetService(“UserInputService”)
local cas = game:GetService(“ContextActionService”)
UIS.InputBegan:Connect(function(Key,IsTyping)
if IsTyping then return end
if Key.KeyCode == Enum.KeyCode.E then
Event:FireServer()
end
end)
The script inside the local script:
local Event = script.Parent:WaitForChild(“RemoteEvent”)
Event.OnServerEvent:Connect(function(Player)
local Char = Player.Character
local HRP = Char.HumanoidRootPart
local Part = Instance.new("Part",workspace)
Part.Name = "FlyingBall"
Part.Shape = "Ball"
Part.BrickColor = BrickColor.new("Really black")
Part.Reflectance = 0
Part.CanCollide = false
Part.Size = Vector3.new(0.125,0.125,0.125)
Part.CFrame = HRP.CFrame * CFrame.new(0,1,-10)
game.Workspace.Sound:Play()
Part.Touched:Connect(function(OtherPart)
local EnemyCharacter = OtherPart.Parent
if EnemyCharacter ~= Character then
local Humanoid = EnemyCharacter.Humanoid
Humanoid.Health = Humanoid.Health-45
Part:Destroy()
end
end)
local BV = Instance.new("BodyVelocity",Part)
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.P = 10000000
BV.Velocity = HRP.CFrame.LookVector * 100
game.Debris:AddItem(Part,3)
end)