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

How to have a build gui without studio crashing/game laag?

Asked by 6 years ago

I have a script for a simple building gui, however after a while the amount of singals sent causes studio to crash. Anyway to stop this? I tried to have it only run if the position isn't equal, but still the signals were too much. Anyway to fix this? Here is my code:

function BuildMode()
    local buildmode = game.ReplicatedStorage.Value.Value
    if buildmode == false then
    buildmode = true
elseif buildmode == true then
    buildmode = false
end
if buildmode == true then   
    print("Build mode on")
    local player = game.Players.LocalPlayer
    local Mouse = player:GetMouse()
    local pgui = player.PlayerGui
    local a = game.Workspace.BrickWall:Clone()
    a.Transparency = .5
    a.CanCollide = false
    a.Parent = workspace
    Mouse.Move:connect(function()
    if buildmode == true then
     if Mouse.Target.Name == "Terrain" then
    if a.CFrame ~= Mouse.Hit then
        a.Anchored = false
        a.CFrame = Mouse.Hit
        Mouse.Idle:connect(function()
            if a.Orientation ~= Vector3.new(0,0,0) then
            a.Orientation = Vector3.new(0,0,0)
            wait(.25)
            a.Anchored = true
            end
        end)
    elseif Mouse.Target.Name == a.Name then
        if a.Orientation ~= Mouse.Target.Orientation then
            a.Orientation = Mouse.Target.Orientation
            a.Position = Mouse.Target.Position + Vector3.new(0,7.2,0)
            a.Anchored = true
        end
    end
    end
        Mouse.Button1Down:connect(function()
            local b = a:Clone()
            b.Parent = workspace
            b.Anchored = true
            b.CanCollide = true
            b.Transparency = 0 
            buildmode = false

        end)
        end
    end)
end
end

script.Parent.MouseButton1Click:connect(BuildMode)
0
Connect ILikeTofuuJoe 1 — 6y
0
You either have a very bad computer or a very bad connection if your roblox studio crashes. greatneil80 2647 — 6y

Answer this question