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

I'm trying to make a build UI button not work if its turned off? (Re-Post!)

Asked by 4 years ago
Edited 4 years ago

Credit to @Feahren for the script, i mostly just edited it, but i am confused why it wont work, and do what i want it to.

Why wont this work? I'm trying to make it so when u build it places a human, and when u click exit build mode u cant build no more? and so that it stays above ground. and easily connectable to if u can. There are no errors.

Local Human placing script:

local Value1 = game.Players.LocalPlayer.Build
local RemoteEvent = game:GetService("ReplicatedStorage").PlaceHuman
local Cursor = game:GetService("Players").LocalPlayer:GetMouse()
script.Parent.MouseButton1Click:Connect(function()

    if Value1.Value == true then
        Cursor.Button1Down:Connect(function()
            while true do
                wait(0.5)
                if Value1.Value == true then
                    RemoteEvent:FireServer(Cursor.Hit.p) -- Hit is the CFrame, p is the Vector3 translation
                else
                    print("cannot complete task")
                end
            end


end)
end

end)

Server-Sided Script:

local Number = 1
local RemoteEvent = game:GetService("ReplicatedStorage").PlaceHuman
RemoteEvent.OnServerEvent:Connect(function(Player, CursorPos) -- Passed Vector3
    local block = game.ReplicatedStorage.Blocks.NPC:Clone()
    block.Parent = workspace
    block.Name = Player.Name.. " 's " ..Number + 1 .. "NPC"
    block:SetPrimaryPartCFrame(CFrame.new(CursorPos))
end)

Local Script For Exit Build Mode:

script.Parent.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.Build.Value = false
end)

Please consider helping as it has got kinda annoying to not be able to keep working on it.

0
I mean, which part of it is not working? Farsalis 369 — 4y
0
mostly the whole thing, where if i try to build it does not work, and if i want to exit build mode it wont work, ill edit for the exit build mode code RobloxGameingStudios 145 — 4y
0
Why dont you just do this in one script... greatneil80 2647 — 4y

Answer this question