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

won't clone to inventory ween clicked with the tool?

@P100D

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local cam = workspace.CurrentCamera
local tool = script.Parent
local fire = tool.Fire1
local ss = game.ReplicatedStorage
local laserpos = ss.MeatLoaf:Clone()
local laser = ss.Laser:Clone()
local clicked = false
local _ss = workspace.ss;
local down = false


laser.Parent,laserpos.Parent,mouse.TargetFilter = cam,cam,cam



----Different Minerals

--Test
mouse.Button1Down:connect(function()
	if clicked == true then
		if mouse.Target.Test.Name == "Test" then
			while clicked == true do
				mouse.Target.Test.Value.Value = mouse.Target.Test.Value.Value-5
				wait(0.5)
				if mouse.Target.Test.Value.Value == -5 then
						local iron = game.ReplicatedStorage.Iron:Clone() --it does not clone
						iron.Parent = game.Players.LocalPlayer.Backpack
					mouse.Target:Destroy()
				end
			end
		end
	end
end)

----Use Script

tool.Equipped:connect(function(mouse)
    local _ss = workspace.ss;
    mouse.Button1Down:connect(function()
        clicked = true
    end)
tool.Unequipped:connect(function(mouse)
      clicked = false
        fire.BrickColor = BrickColor.Black()
        cam.MeatLoaf.Position = _ss.Position
        cam.Laser.Position = _ss.Position
    end)
    mouse.Button1Up:connect(function()
        clicked = false
		down = false
        fire.BrickColor = BrickColor.Black()
        cam.MeatLoaf.Position = _ss.Position
        cam.Laser.Position = _ss.Position
    end)
 	if script.Parent.LS.Value.Value == 0 then
        clicked = false
		down = false
        fire.BrickColor = BrickColor.Black()
        cam.MeatLoaf.Position = _ss.Position
        cam.Laser.Position = _ss.Position
end
end)


while wait(0.05) do
    if clicked then
		if script.Parent.LS.Value.Value > 0 then
        fire.BrickColor = BrickColor.Red()
game.Workspace.Camera.MeatLoaf.Position=mouse.Hit.p
        local dist = (laserpos.CFrame.p - fire.CFrame.p).magnitude
		;
        laser.Size = Vector3.new(dist,0.25,.25)
        laser.CFrame = CFrame.new(fire.CFrame.p,laserpos.CFrame.p) * CFrame.new(0,0,-dist/2) * CFrame.Angles(0,math.rad(90),0);
		script.Parent.LS.Value.Value = script.Parent.LS.Value.Value - 1
        laser.Transparency = 0;
    else
       clicked = false
		down = false
        fire.BrickColor = BrickColor.Black()
        cam.MeatLoaf.Position = _ss.Position
        cam.Laser.Position = _ss.Position
end
    end
    if clicked == false then
		script.Parent.LS.Value.Value = script.Parent.LS.Value.Value +2
    end

end

1 answer

You've already defined the player to define the mouse of the player. So instead of doing:

iron.Parent = game.Players.LocalPlayer.Backpack

do

iron.Parent = plr.Backpack

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