Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
PolyyDev 214 Moderation Voter
6 years ago

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
0
Instead of Lighting, use ReplicatedStorage unless its a folder. AlwaysFris 0 — 6y
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. SimpleFlame 255 — 6y
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. PolyyDev 214 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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.

0
Thanks, i'm so dumb lmao! PolyyDev 214 — 6y
Ad

Answer this question