I’m making a building system and I have everything done, but now it’s giving me an error saying:
Expected identifier when parsing expression, got ‘)’ - Studio - EditScript:103
local mouse = game.Players.LocalPlayer:GetMouse()
local hold = false
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("BuildPart")
local guiclicked = false
local clickDB = false
script.Parent.MouseButton1Click:Connect(function()
if guiclicked == true then
workspace.editMode:ClearAllChildren()
guiclicked = false
return
end
guiclicked = true
local selectionPart = game.ReplicatedStorage.items.BasePart:Clone()
selectionPart.Transparency = .5
selectionPart.CanCollide = false
local clicker = Instance.new("ClickDetector")
clicker.CursorIcon = "rbxassetid://7545920160"
clicker.MaxActivationDistance = 99999999
selectionPart.Parent = workspace.editMode
clicker.Parent = selectionPart
local dragPos1
local dragPos2
local pLen
local pWid
while guiclicked == true do
local position = mouse.Hit.p
if position then
selectionPart.Position = Vector3.new(math.ceil((position.X-3)/6)*6,2,math.ceil((position.Z-3)/6)*6)
end
UserInputService.InputBegan:Connect(function(inputObject)
if hold == false then
if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
hold = true
dragPos1 = Vector3.new(math.ceil((position.X-3)/6)*6,2,math.ceil((position.Z-3)/6)*6)
end
end
end)
UserInputService.InputEnded:Connect(function(inputObject)
if hold == true then
if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
hold = false
dragPos2 = Vector3.new(math.ceil((position.X-3)/6)*6,2,math.ceil((position.Z-3)/6)*6)
local lowX = math.min(dragPos1.X,dragPos2.X)
local lowZ = math.min(dragPos1.Z,dragPos2.Z)
if dragPos1.X-lowX ~= 0 then
pLen = (dragPos1.X-lowX)/6
else if dragPos2.X-lowX ~= 0 then
pLen = (dragPos2.X-lowX)/6
else if dragPos1.X-lowX == 0 or dragPos2.X-lowX == 0 then
pLen = 0
end
if dragPos1.Z-lowZ ~= 0 then
pWid = (dragPos1.Z-lowZ)/6
else if dragPos2.Z-lowZ ~= 0 then
pWid = (dragPos2.Z-lowZ)/6
else if dragPos1.Z-lowZ == 0 or dragPos2.Z-lowZ == 0 then
pWid = 0
end
if dragPos1.X == lowX then
for i=0, pLen do
if dragPos1.Z == lowZ then
for i=0, pWid do
dragPos1.Z += i*6
selectionPart.Name = dragPos1.X/6 .."-"..dragPos1.Z/6
remoteEvent:FireServer(selectionPart.Name,selectionPart.Color,dragPos1)
end
else if dragPos2.Z == lowZ then
for i=0, pWid do
dragPos1.Z += i*6
selectionPart.Name = dragPos2.X/6 .."-"..dragPos2.Z/6
remoteEvent:FireServer(selectionPart.Name,selectionPart.Color,dragPos2)
end
end
dragPos1.X += i*6
end
else if dragPos2.X == lowX then
for i=0, pLen do
if dragPos1.Z == lowZ then
for i=0, pWid do
dragPos1.Z += i*6
selectionPart.Name = dragPos2.X/6 .."-"..dragPos2.Z/6
remoteEvent:FireServer(selectionPart.Name,selectionPart.Color,dragPos1)
end
else if dragPos2.Z == lowZ then
for i=0, pWid do
dragPos2.Z += i*6
selectionPart.Name = dragPos2.X/6 .."-"..dragPos2.Z/6
remoteEvent:FireServer(selectionPart.Name,selectionPart.Color,dragPos2)
end
end
dragPos2.X += i*6
end
end
end
end
end)
--[[
clicker.MouseClick:Connect(function()
if clickDB == false then
selectionPart.Name = selectionPart.Position.X/6 .."-"..selectionPart.Position.Z/6
remoteEvent:FireServer(selectionPart.Name,selectionPart.Color,selectionPart.Position)
clickDB = true
wait(0.01)
clickDB = false
end
end)
]]--
wait(.01)
end
end)