So I’m working on a script and i just want to kinda simplify it before i move on to the larger part of it.
–Here’s The Script
local tool = script.Parent
local char = tool.Parent
local player = game.Players:GetPlayerFromCharacter(char)
local PrimaryPart = char.PrimaryPart
local Constructing = false
-- ToolActivated Function Variables
local ToolValue = 0
-- Option1Pressed Function Variables
local CurrentlyBuild = false
local Build1
local function ToolActivated()
ToolValue += 1
if ToolValue == 1 and CurrentlyBuild == false and Constructing == false then
player.PlayerGui.BuildMenu.Enabled = true
else
player.PlayerGui.BuildMenu.Enabled = false
print("check")
end
end
local function Option1Pressed()
Constructing = true
if not Build1 then
Build1 = game.ReplicatedStorage.Build1:Clone()
end
if CurrentlyBuild == false then
CurrentlyBuild=true
player.PlayerGui.BuildMenu.Enabled = false
ToolValue = 0
--Build1 Position Selection
Build1.Parent = game.Workspace
while task.wait(0.01) do
if ToolValue ~= 1 then
Build1.PrimaryPart.CFrame = CFrame.new(PrimaryPart.CFrame.Position.X,2,PrimaryPart.CFrame.Position.Z-5)
CurrentlyBuild=false
ToolValue = 0
else
break
end
end
end
end
tool.Activated:Connect(ToolActivated)
game.ReplicatedStorage.Option1.OnServerEvent:Connect(Option1Pressed)