Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Tool shooting when I'm not holding it, why is it shooting even with an Equipped function?

Here's my script I was trying to get it to only shoot when I hold it out but it continues to shoot anyways


local Part = game.ReplicatedStorage.Fireball
local Tool = script.Parent
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
script.Parent.Equipped:Connect(function()
	Mouse.Button1Up:Connect(function()
			local partclone = Part:Clone()
			local PlayerPos = Player.Character.HumanoidRootPart.Position
			partclone.CFrame = Tool.Handle.CFrame
			local Vel = Instance.new("BodyVelocity",partclone)
			Vel.P = Vector3.new(100000,100000,100000)
			Vel.Velocity = Mouse.Hit.LookVector * 100
			partclone.Parent = game.Workspace
		end)
	end)

If you know a fix, send it please.

1 answer

So I see one thing that's wrong with this. I don't do guns but I know it's supposed to shoot when the mouse it down not up. Just change line 7 to this.

Mouse.Button1Down

Also, before posting, look on the DevHub then DevForum before coming here. Also, look at this. It has some good information for what you're doing.

This discussion is preserved as it was. New answers, comments, and votes are closed.