Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tool = script.Parent
- local player = game:GetService("Players").LocalPlayer
- local mousedown = false
- tool.Equipped:Connect(function(mouse)
- print("Tool equipped!")
- local ammo = player.PlayerGui.AmmoGUI.Main.Ammo
- local name = player.PlayerGui.AmmoGUI.Main.GunName
- local main = player.PlayerGui.AmmoGUI
- local holdAnim = Instance.new("Animation")
- holdAnim.AnimationId = "http://www.roblox.com/Asset?ID="..tool.Stats.AnimID.Value
- local holdAnimTrack = player.Character.Humanoid:LoadAnimation(holdAnim)
- holdAnimTrack:Play()
- main.Enabled = true
- ammo.Text = tool.Stats.Ammo.Value .."/"..tool.Stats.MaxAmmo.Value
- name.Text = tool.Name
- tool.Unequipped:Connect(function()
- main.Enabled = false
- holdAnimTrack:Stop()
- end)
- tool.Stats.Ammo.Changed:Connect(function()
- ammo.Text = tool.Stats.Ammo.Value .."/"..tool.Stats.MaxAmmo.Value
- end)
- mouse.Button1Down:Connect(function()
- local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.ShootPart.CFrame.p).unit * 300)
- local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
- script.Parent.Remotes.CreateRay:FireServer(part, position)
- end)
- end)
- script.Parent:WaitForChild("Remotes").CreateRay.OnClientEvent:Connect(function(part, position)
- local beam = Instance.new("Part", workspace.Rays)
- beam.BrickColor = BrickColor.new("Bright yellow")
- beam.FormFactor = "Custom"
- beam.Material = "Neon"
- beam.Transparency = 0.25
- beam.Anchored = true
- beam.Locked = true
- beam.CanCollide = false
- beam.Name = "beam"
- local distance = (tool.Handle.CFrame.p - position).magnitude
- beam.Size = Vector3.new(0.2, 0.2, distance)
- beam.CFrame = CFrame.new(tool.ShootPart.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
- game["Run Service"].Heartbeat:Connect(function()
- beam.Transparency = beam.Transparency + 0.05
- end)
- game:GetService("Debris"):AddItem(beam, 0.5)
- if part then
- if part.Parent then
- local humanoid = part.Parent:FindFirstChild("Humanoid")
- if not humanoid then
- humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
- end
- if humanoid then
- script.Parent.Remotes.Damage:FireServer(humanoid)
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement