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

Trying to put a gun in Back pack but nothing happens, can anyone help?

Its probably a stupid mistake I have made like usual or I just did it wrong. Its a LocalScript if that helps Someone please look at it and try to help

local frame = script.Parent.Parent
local blur = game.Lighting:WaitForChild("Blur")
local player = game.Players.LocalPlayer
local output = script.Parent.Parent.Output
while true do
script.Parent.MouseButton1Click:Connect(function()
	frame:TweenPosition(UDim2.new(-1,0,-0.052,0), "In", "Sine", 1.5)
	wait(0.3)
	repeat blur.Size = blur.Size - 0.1 wait(0.01) until blur.Size == 0
	blur.Enabled = false
	player.Character:MoveTo(Vector3.new(-202, 6.1, 44))
	if blur.Size >= 0 then
		blur.Size = 0
---------------------Class Module By Ki_ngPhantom---------------------
		local lighting = game:GetService("Lighting")
		local guns = lighting.Guns
		local pack = player.Backpack
		if output.Text == "Class: Assault" then
			local AKM = guns.Assault.AKM:Clone()
			AKM.Parent = pack
			local M9 = guns.Assault.M1911
			M9.Parent = pack
		end
	end
	
	
end)
end

3 comments

0

Instead of Lighting, use ReplicatedStorage unless its a folder.

0

First, whats the error you're getting? Also you don't need that "while true do" because the code will only run if the button is click.

0

No error, just nothing. But I know the problem know anyway. It was I had FE on for testing and I din't turn it off. Now I have and the game is just freezing. I have made another question on, go check it out.

1 answer

✓ Accepted answer

I don't believe this has anything to do with FilteringEnabled; the problem is that you have a while true do starting on line 5, and all it does is continually make connections to the same anonymous function forever. (Remember that the wait commands inside the anonymous function won't execute until MouseButton1Click occurs, which can't happen if your game is frozen. Further, as SimpleFrame suggests, you don't need to connect the event more than once.) Remove the while loop and your game should stop freezing.

1 comment

0

Thanks, i'm so dumb lmao!

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