-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerBulletCreate.lua
More file actions
81 lines (64 loc) · 2.41 KB
/
ServerBulletCreate.lua
File metadata and controls
81 lines (64 loc) · 2.41 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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 debounce = false
local function shootBullet()
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 == script:GetAttribute("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.bullets
newBullet:SetNetworkOwner(nil)
newBullet.CollisionGroup = "bullets"
--newBullet.CFrame = CFrame.lookAt(newBullet.Position, newBullet.Position + directionVector)
--[[
local waitScript = ReplicatedStorage.bulletWait:Clone()
waitScript:SetAttribute("propertyOf",script:GetAttribute("propertyOf"))
waitScript.Parent = newBullet
waitScript.Enabled = true
]]--
--[[
for j,v in pairs(game.Players:GetChildren()) do
local fakeBullet = newBullet:Clone()
fakeBullet.bulletShape.Transparency = 0
fakeBullet.Parent = game.Workspace.fakeBullets
fakeBullet.CollisionGroup = "ignore"
fakeBullet:SetNetworkOwner(v)
--fakeBullet.Position = newBullet.Position
--fakeBullet.Velocity = newBullet.Velocity
end
]]--
--[[
newBullet.Touched:Connect(function(hit)
print(hit.Parent.Name)
if hit.Parent.Name == workspace.enemies.Name or hit.Parent.Name == workspace.bullets.Name then
hit = nil
else
newBullet:Destroy()
if hit.Parent.Name == workspace.player.Name then
end
end
end)
]]--
--[[
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)
break
end
end
]]--
task.wait(script:GetAttribute("sps"))
debounce = false
end
end
RunService.Heartbeat:Connect(shootBullet)