It is ok if its in a different script
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local k = Instance.new("Part")
local Tool = script.Parent.Parent
local canshoot = false
Tool.Equipped:Connect(function()
canshoot = true
end)
Tool.Unequipped:Connect(function()
canshoot = false
end)
Mouse.Button1Down:Connect(function()
if canshoot == true then
wait(0.5)
k.Parent = game.Workspace
k.Color = Color3.fromRGB(1,1,1)
k.Size = Vector3.new(0.08, 0.08, 0.08)
k.Anchored = true
k.CanCollide = false
k.Position = Vector3.new(Mouse.Hit)
k.CFrame = Mouse.Hit
script.Parent.Shoot:Play()
repeat wait(.001) script.Parent.PointLight.Enabled = true until script.Parent.Shoot.Playing == false
if script.Parent.Shoot.Playing == false then
script.Parent.PointLight.Enabled = false
end
end
end)
function onTouched(hit)
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) then
human.Health = human.Health - 7
if k.Touched then
k:Destroy()
end
end
end
k.Touched:connect(onTouched)

1 comment
The below answer is rubbish, just dedicate a script to do the server stuff, and dedicate a local script to doing the client stuff, and use a either a RemoteEvent or a RemoteFunction to communicate between the server and the client.