I'm making something on ROBLOX and the script only seems to work in solo test mode but not in the real roblox server. So I need some help fixing this mistake and being successful.
local GUI = script.Parent
local Cam = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local User = Player.Character
local _Tool = Instance.new("Tool")
local Click = false
local Q = false
local Toggle = false
local Weld1 = nil
local Weld2 = nil
local Rope1 = nil
local Rope1Pos = nil
local Rope2 = nil
local Rope2Pos = nil
local Target = nil
local Tool = "Move"
local Tab = "Basic"
local Items = {
Basic = {
{Name = "Crate",
ID = "http://www.roblox.com/asset/?id=51710801"
},
{Name = "Bathtub",
ID = "http://www.roblox.com/asset/?id=51713958"
}
}
}
repeat wait() until workspace:FindFirstChild("Work "..Player.Name)
local Work = workspace:FindFirstChild("Work "..Player.Name)
for i = 1,12 do
if Items[Tab][i] then
GUI.Items[i].ItemName.Text = Items[Tab][i].Name
GUI.Items[i].Image.Image = Items[Tab][i].ID
end
GUI.Items[i].Use.MouseButton1Down:connect(function()
if Items[Tab][i] then
local Model = game.Lighting.Assets[Items[Tab][i].Name]:Clone()
Model.Parent = Work
Model.PrimaryPart = Model.Base
for Index,Part in pairs (Model:GetChildren()) do
if Part:isA("BasePart") and Part ~= Model.PrimaryPart then
local Weld = Instance.new("Weld",Model)
Weld.Part0 = Model.PrimaryPart
Weld.Part1 = Part
Weld.C0 = Model.PrimaryPart.CFrame:toObjectSpace(Part.CFrame)
end
Part.Anchored = false
end
local Size = Model:GetModelSize()
Model:moveTo(User.Torso.CFrame.p+(User.Torso.CFrame.lookVector*((Size.magnitude/2)+3)))
end
end)
end
GUI.Items.Basic.MouseButton1Down:connect(function()
Tab = "Basic"
for i = 1,12 do
if Items[Tab][i] then
GUI.Items[i].ItemName.Text = Items[Tab][i].Name
GUI.Items[i].Image.Image = Items[Tab][i].ID
end
end
end)
for Index,Button in pairs (GUI.Tools:GetChildren()) do
Button.MouseButton1Down:connect(function()
Tool = Button.Name
end)
end
local Handle = Instance.new("Part",_Tool)
Handle.Name = "Handle"
_Tool.Equipped:connect(function(mouse)
_Tool.Parent = nil
mouse.Button1Down:connect(function()
Click = true
Target = mouse.Target
if not Target then
Weld1 = nil
Weld2 = nil
Rope1 = nil
Rope2 = nil
end
if Target then
if Target:IsDescendantOf(Work) then
if Tool == "Rope" then
if not Rope1 then
Rope1 = Target
Rope1Pos = mouse.Hit.p
elseif not Rope2 then
Rope2 = Target
Rope2Pos = mouse.Hit.p
end
if Rope1 and Rope2 then
if Rope1 == Rope2 then
Rope1 = nil
Rope2 = nil
else
local Rope = game.Lighting.Assets.Rope:Clone()
Rope.PrimaryPart = Rope.Base
Rope.Parent = Work
Rope.PrimaryPart.CFrame = CFrame.new(Rope1Pos,Rope2Pos)*CFrame.Angles(math.rad(90),0,0)*CFrame.new(0,-0.5,0)
local Glue = Instance.new("Glue",Rope)
Glue.Part0 = Rope.PrimaryPart
Glue.Part1 = Rope1
Glue.C0 = CFrame.new(0,0.5,0)
Glue.C1 = Rope1.CFrame:toObjectSpace(CFrame.new(Rope1Pos))
local End1 = nil
local End2 = nil
local Last = Rope.PrimaryPart
for i = 1,math.floor((Rope1Pos-Rope2Pos).magnitude/2)+2 do
local String = Rope.PrimaryPart:Clone()
String.Name = "String"
String.Parent = Rope
String.CFrame = Last.CFrame * CFrame.new(0,-1,0)
local Glue = Instance.new("Glue",Rope)
Glue.Part0 = String
Glue.Part1 = Last
Glue.C0 = CFrame.new(0,0.5,0)
Glue.C1 = CFrame.new(0,-0.5,0)
Last = String
End1 = String
end
local String = Rope.PrimaryPart:Clone()
String.Name = "String"
String.Parent = Rope
String.CFrame = CFrame.new(Rope2Pos,Rope1Pos)*CFrame.Angles(math.rad(90),0,0)*CFrame.new(0,-0.5,0)
local Glue = Instance.new("Glue",Rope)
Glue.Part0 = String
Glue.Part1 = Rope2
Glue.C0 = CFrame.new(0,0.5,0)
Glue.C1 = Rope2.CFrame:toObjectSpace(CFrame.new(Rope2Pos))
Last = String
for i = 1,math.floor((Rope2Pos-Rope1Pos).magnitude/2)+2 do
local String = Rope.PrimaryPart:Clone()
String.Name = "String"
String.Parent = Rope
String.CFrame = Last.CFrame * CFrame.new(0,-1,0)
local Glue = Instance.new("Glue",Rope)
Glue.Part0 = String
Glue.Part1 = Last
Glue.C0 = CFrame.new(0,0.5,0)
Glue.C1 = CFrame.new(0,-0.5,0)
Last = String
End2 = String
end
local Glue = Instance.new("Glue",Rope)
Glue.Part0 = End1
Glue.Part1 = End2
Glue.C0 = CFrame.new(0,-0.5,0)
Glue.C1 = CFrame.new(0,0.5,0)
wait()
for Index,Child in pairs (Rope:GetChildren()) do
if Child:isA("BasePart") then
Child.Velocity = Vector3.new(0,0,0)
Child.RotVelocity = Vector3.new(0,0,0)
end
end
Rope1 = nil
Rope2 = nil
end
end
end
if Tool == "Remove" then
Target.Parent.Parent = nil
end
if Tool == "Balloon" and Target.Parent.Name ~= "Balloon" then
local Balloon = game.Lighting.Assets.Balloon:Clone()
Balloon.PrimaryPart = Balloon.Base
Balloon.Parent = Target.Parent
Balloon.Base.Color = Color3.new(math.random(),math.random(),math.random())
local Weld = Instance.new("Weld",Balloon)
Weld.Part0 = Balloon.String
Weld.Part1 = Balloon.Base
Weld.C0 = CFrame.new(0,3.5,0)
Balloon.String.CFrame = CFrame.new(mouse.Hit.p+Vector3.new(0,3,0))
local Glue = Instance.new("Glue",Balloon)
Glue.Part0 = Balloon.String
Glue.Part1 = Target
Glue.C0 = CFrame.new(0,-3,0)
Glue.C1 = Target.CFrame:toObjectSpace(Balloon.String.CFrame*CFrame.new(0,-3,0))
end
if Tool == "Weld" then
for Index,Part in pairs (Target.Parent:GetChildren()) do
if Part:isA("BasePart") then
Part.Anchored = false
end
end
if not Weld1 then
Weld1 = Target.Parent
elseif not Weld2 then
Weld2 = Target.Parent
end
if Weld1 and Weld2 then
if Weld1 == Weld2 then
Weld1 = nil
Weld2 = nil
else
local Relation = Weld2.Base.CFrame:toObjectSpace(Weld1.Base.CFrame)
local Weld = Instance.new("Weld",Weld2)
Weld.Part0 = Weld2.Base
Weld.Part1 = Weld1.Base
Weld.C0 = Relation
Weld1.Base.Name = Weld1.Name
for Index,Child in pairs (Weld1:GetChildren()) do
Child.Parent = Weld2
end
Weld1.Parent = nil
Weld1 = nil
Weld2 = nil
end
end
Target = nil
end
if Tool == "Rotate" then
local Anchor = Target.Parent.Base.Anchored
for Index,Part in pairs (Target.Parent:GetChildren()) do
if Part:isA("BasePart") then
Part.Anchored = false
end
end
mouse.TargetFilter = Target
local Pos = Instance.new("BodyPosition",Target.Parent.PrimaryPart)
Pos.maxForce = Vector3.new(math.huge,math.huge,math.huge)
Pos.position = Target.Parent.PrimaryPart.CFrame.p
local Gyro = Instance.new("BodyGyro",Target.Parent.PrimaryPart)
Gyro.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
Gyro.cframe = Target.Parent.PrimaryPart.CFrame
while Click do
wait()
Gyro.cframe = CFrame.new(Pos.position,mouse.Hit.p)
end
for Index,Part in pairs (Target.Parent:GetChildren()) do
if Part:isA("BasePart") then
if Anchor then
Part.Anchored = true
end
Part.Velocity = Vector3.new(0,0,0)
Part.RotVelocity = Vector3.new(0,0,0)
end
end
Pos.Parent = nil
Gyro.Parent = nil
mouse.TargetFilter = nil
Target = nil
end
if Tool == "Move" then
for Index,Part in pairs (Target.Parent:GetChildren()) do
if Part:isA("BasePart") then
Part.Anchored = false
end
end
mouse.TargetFilter = Target
local Pos = Instance.new("BodyPosition",Target.Parent.PrimaryPart)
Pos.maxForce = Vector3.new(math.huge,math.huge,math.huge)
Pos.position = Target.Parent.PrimaryPart.CFrame.p
local Gyro = Instance.new("BodyGyro",Target.Parent.PrimaryPart)
Gyro.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
Gyro.cframe = Target.Parent.PrimaryPart.CFrame
local Size = Target.Parent:GetModelSize()
while Click do
wait()
Pos.position = User.Torso.CFrame.p+((mouse.Hit.p-User.Torso.CFrame.p).unit*((Size.magnitude/2)+3))
end
for Index,Part in pairs (Target.Parent:GetChildren()) do
if Part:isA("BasePart") then
Part.Velocity = Vector3.new(0,0,0)
Part.RotVelocity = Vector3.new(0,0,0)
end
end
Pos.Parent = nil
Gyro.Parent = nil
mouse.TargetFilter = nil
Target = nil
end
end
end
end)
mouse.Button1Up:connect(function()
Click = false
end)
mouse.KeyDown:connect(function(key)
if key == "1" then
Tool = "Move"
end
if key == "2" then
Tool = "Rotate"
end
if key == "3" then
Tool = "Weld"
end
if key == "4" then
Tool = "Remove"
end
if key == "e" then
if Target then
if Target.Parent then
if Tool == "Move" then
for Index,Part in pairs (Target.Parent:GetChildren()) do
if Part:isA("BasePart") then
Part.Anchored = true
end
end
end
end
end
end
if key == "z" then
Toggle = not Toggle
end
if key == "q" then
Q = true
GUI.Items:TweenPosition(UDim2.new(0.5,-430,0.5,-255),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1,Q)
GUI.Tools:TweenPosition(UDim2.new(0.5,210,0.5,-255),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1,Q)
Q = false
end
end)
mouse.KeyUp:connect(function(key)
if key == "q" then
Q = true
GUI.Items:TweenPosition(UDim2.new(0,-640,0.5,-255),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1,Q)
GUI.Tools:TweenPosition(UDim2.new(0.5,210,0,-510),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1,Q)
Q = false
end
end)
end)
_Tool.Parent = User

4 comments
So you give us no explanation of the script, and give us a 324 lined script and expect us to do it all for you?
Bruh, there is no way im gonna read through 324 lines of any code, much less messy, untabbed code.
The script is for opening up a gui to spawn parts into the map.
Well that doesn't really help us. I can tell you right now though, don't stack up so many if statements. Use 'elseif' and 'and'.