-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientBulletCreate.lua
More file actions
42 lines (31 loc) · 1.4 KB
/
ClientBulletCreate.lua
File metadata and controls
42 lines (31 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
local RunService = game:GetService("RunService")
local serverStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local newBulletTemplate = ReplicatedStorage.Assets.bulletAssets:WaitForChild(script:GetAttribute("bulletType"))
local propertyOf = script:GetAttribute("propertyOf")
local debounce = false
local function shootFakeBullet()
if not debounce then
debounce = true
local newBullet = newBulletTemplate:Clone()
newBullet.Orientation = Vector3.new(0,0,script:GetAttribute("rotation"))
local directionVector = Vector3.new(0,math.sin(math.rad(newBullet.Orientation.Z)),math.cos(math.rad(newBullet.Orientation.Z)))
for i,v in pairs(game.Workspace.enemies:GetChildren()) do
if v:IsA("Part") and v.Name == propertyOf then
newBullet.Position = Vector3.new(224,v.Position.Y,v.Position.Z)
end
end
newBullet.CFrame = CFrame.lookAt(newBullet.Position, newBullet.Position + directionVector)
newBullet.Velocity = directionVector * script:GetAttribute("bulletSpeed")
newBullet.Parent = game.Workspace.fakeBullets
for i,v in pairs(game.Players:GetChildren()) do
if v.Name and v.Name == script:GetAttribute("clientOwner") then
newBullet:SetNetworkOwner(v)
end
end
newBullet.CollisionGroup = "ignore"
task.wait(script:GetAttribute("sps"))
debounce = false
end
end
RunService.Heartbeat:Connect(shootFakeBullet)