Hello, I am currently having trouble finding a way to add creator tags to my guns that I made. I could really use help.
Local Script in gun:
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Tool = script.Parent
local Cooldown = false
local COOLDOWN_TIME = 0.5
local function Pew()
Tool.Handle.PointLight.Enabled = true
game.ReplicatedStorage.ShootGun:FireServer(Mouse.Hit.p, Tool.Handle)
end
local function Shoot()
if Cooldown == true then
return
end
Cooldown = true
Pew()
print("SHOOTING")
wait(COOLDOWN_TIME)
Cooldown = false
Tool.Handle.PointLight.Enabled = false
end
Tool.Activated:Connect(function()
Shoot()
end)
Script in server script service:
local RANGE = 525
local DAMAGE = 20
game.ReplicatedStorage.ShootGun.OnServerEvent:Connect(function(Player, TargetLocation, Handle)
if Player.Character == nil then
return
end
Handle.Sound:Play()
local Beam = Instance.new("Part", workspace)
Beam.BrickColor = BrickColor.new("New Yeller")
Beam.FormFactor = "Custom"
Beam.Transparency = 0.25
Beam.Material = "Neon"
Beam.Anchored = true
Beam.CanCollide = false
local Distance = (Handle.Position - TargetLocation).magnitude
Beam.Size = Vector3.new(0.1, 0.1, Distance)
Beam.CFrame = CFrame.new(Handle.Position, TargetLocation) * CFrame.new(0, 0, -Distance/2)
game.Debris:AddItem(Beam, 0.1)
local NewRay = RaycastParams.new()
local RayDirection = (TargetLocation - Handle.Position) * RANGE
NewRay.FilterDescendantsInstances = {Player.Character}
local Result = workspace:Raycast(Handle.Position, RayDirection, NewRay)
if Result then
if Result.Instance then
if Result.Instance.Parent:FindFirstChild("Humanoid") then
Result.Instance.Parent.Humanoid.Health -= DAMAGE
end
end
end
end)