Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local but = script.Parent
- local isBuilding = script.Building --just so that external scripts can see this shtuff
- local bID = script.BlockID --currently we arn't going to do much with this until we get other scripts/blocks
- local typing = false
- local con = but.Parent
- local pGUI = con.Parent
- local plr = pGUI.Parent
- local tGui = con.BuildHelp
- local char = workspace:WaitForChild(plr.Name)
- local coms = game.ReplicatedStorage.Build
- local access = game.ReplicatedStorage.BuildAccess
- local bind = con.Parent:WaitForChild("BuildMessage")
- local dDebounce = true
- local dTimer = 3
- local passes = {
- "ToolEquip",
- "ToolUnequip",
- }
- local Image1 = "rbxassetid://2220069704"
- local Image2 = "rbxassetid://2220069316"
- local function tutorial()
- if isBuilding.Value then
- tGui:TweenPosition(UDim2.new(0.91, 0, 0.14, 0), Enum.EasingDirection.In, Enum.EasingStyle.Linear, 1)
- wait(0.1)
- elseif not isBuilding.Value then
- tGui:TweenPosition(UDim2.new(1.17, 0, 0.14, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 1)
- wait(0.1)
- end
- end
- local function activate()
- if isBuilding.Value == false then
- coms:FireServer(passes[1])
- --isBuilding.Value = not isBuilding.Value
- elseif isBuilding.Value == true then
- coms:FireServer(passes[2])
- --isBuilding.Value = not isBuilding.Value
- end
- end
- local function message(text)
- dDebounce = false
- wait() --that's a whole lotta waits
- local s = script.BuildDialogue:Clone()
- s.Parent = con
- if text then
- s.TextLabel = text
- end
- s:TweenPosition(UDim2.new(0.125, 0, 0.625, 0), Enum.EasingDirection.In, Enum.EasingStyle.Linear, 0.5)
- wait(dTimer)
- s:TweenPosition(UDim2.new(-0.126, 0, 0.625, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.5)
- wait(0.5)
- s:Destroy()
- dDebounce = true
- --print("Boom, message done")
- end
- local function scan()
- while true do
- wait()
- --if the build tutorial is out when not building or vice versa
- if isBuilding.Value == false and tGui.Position == UDim2.new(0.91, 0, 0.14, 0) then
- tutorial()
- elseif isBuilding.Value == true and tGui.Position == UDim2.new(1.17, 0, 0.14, 0) then
- tutorial()
- end
- --if the gui hides itself
- if but.Parent.Enabled == false then
- isBuilding.Value = false
- but.Image = Image2
- if char:FindFirstChild("Hammer") then
- coms:FireServer(passes[2])
- end
- end
- --if the player gets an orb during buildmode
- local c = access:InvokeServer("Tools?")
- repeat wait() until c
- if c then
- local low = string.lower(c.Name)
- if string.find(low, "orb") then
- isBuilding.Value = false
- but.Image = Image2
- end
- end
- end
- end
- isBuilding.Changed:Connect(function() --tutorial
- tutorial()
- end)
- coms.OnClientEvent:Connect(function(pass)
- if pass == passes[1] then
- isBuilding.Value = true
- but.Image = Image1
- elseif pass == passes[2] then
- isBuilding.Value = false
- but.Image = Image2
- end
- end)
- print("Connecting Event!")
- bind.Event:Connect(function(mess) --client access to messaging
- print("Recieved an Event")
- if dDebounce then
- print("Doing the message!")
- message(mess)
- end
- end)
- print("Event Connected!")
- plr.CharacterAdded:Connect(function(char)
- char.ChildRemoved:Connect(function(child)
- if child.Name == 'Hammer' then
- -- coms:FireServer(passes[2])
- isBuilding.Value = false
- but.Image = Image2
- end
- end)
- end)
- coms.OnClientEvent:Connect(function(pass)
- if pass == "TooMany" and dDebounce then
- message()
- elseif pass == "NoWood" and dDebounce then
- message("You have used all of your wood!")
- end
- end)
- game:GetService("UserInputService").InputBegan:Connect(function(key, gpe)
- if gpe then return end
- if (key.KeyCode == Enum.KeyCode.B or key.KeyCode == Enum.KeyCode.ButtonB) then --both keyboard and gamepad
- if but.Parent.Enabled then
- activate()
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement