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

My gun is stuck to my fingers, please help?

I know it does this becuase i do not have the equip/unequip function, but i already have a function. Honestly, i've never tried adding 2 functions because it sounds stupid

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local k = Instance.new("Part")
Mouse.Button1Down:Connect(function()
	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)
    -- If the above does not work, remove the -- before the following line and remove the line above.
    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

1 comment

0

i mean when i unequip it still shoots. i have finger guns

1 answer

✓ Accepted answer
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local k = Instance.new("Part")
local Tool = script.Parent.Parent
local canshoot = false

Tool.Equped: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)

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