Update: Turns out I had to make the main script a local script :/
I made a basic weapon and it works in Play Solo, but when I publish the game, it doesn't work.
The weapon has 2 scripts, the main one is a non-local script in the handle.
local Debounce = true
function onEquip(Mouse)
local Character = script.Parent.Parent.Parent
local Torso = Character.Torso
Mouse.Icon = "rbxasset://textures\\GunCursor.png"
function onClick(Mouse)
if Torso then
if Debounce then
Debounce = false
Mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
local Location = Mouse.Hit
script.Parent.Fire:Play()
x = Instance.new("Part")
y = Instance.new("BodyForce")
z = script.Parent.Parent.BulletScript:Clone()
x.FormFactor = 3
x.Size = Vector3.new(0.2, 0.2, 1.6)
x.Name = "Laser"
x.BrickColor = BrickColor.new("Really red")
x.CFrame = CFrame.new(script.Parent.Position + (script.Parent.CFrame.lookVector * 3),(Mouse.UnitRay.Direction * 1000))
x.Velocity = x.CFrame.lookVector * 200
z.Parent = x
z.Disabled = false
y.force = Vector3.new(0, 12.5, 0)
y.Parent = x
x.Parent = Workspace
wait(1)
Debounce = true
Mouse.Icon = "rbxasset://textures\\GunCursor.png"
end
end
end
Mouse.Button1Down:connect(function()onClick(Mouse)end)
end
script.Parent.Parent.Equipped:connect(onEquip)
The other one which is located directly in the tool is also non-local, and is responsible for doing damage.
local x = script.Parent
function onTouch(part)
local Character = part.Parent:FindFirstChild("Humanoid")
if Character then
Character:TakeDamage(25)
x:Destroy()
else
x:Destroy()
end
end
x.Touched:connect(onTouch)
Sorry if there is an obvious mistake, I am just starting out.

1 comment
Any script that has to deal with the mouse should always be local.