generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Need a pretty good scripter...Help!

Previous Thread :: Next Thread 
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
24 Sep 2011 07:09 PM
I have this script for a CFrame Studio Plugin. I upload a CFrame Gui from my models, and I know all of the paths in it are correct. When I click one of the buttons in the Gui, it's supposed to CFrame it accordingly. I'm pretty sure the problem is in the Position() function and the Angles() function. I'm not getting any output. Here is the entire script:

inUse = false
load = false
cframeplugin = PluginManager():CreatePlugin()
cframetoolbar = cframeplugin:CreateToolbar("CFrame")
cframebutton = cframetoolbar:CreateButton("CFrame", "CFrame", "")
cframegui = nil
modelchil = {}
xs = {}
ys = {}
zs = {}

cframeplugin.Deactivation:connect(function() turnOff() end)

function turnOn()
if (inUse == true) then
turnOff()
elseif (load == true and inUse == false) then
inUse = true
asset = game:GetService("InsertService"):LoadAsset(62283588)
cframegui = asset.CframeGui
cframegui.Parent = game.CoreGui
asset:Remove()
for i, v in pairs(cframegui.Frame:GetChildren()) do
if (v.Name:sub(2, 2) == "P" and #v.Name ~= 2) then
v.MouseButton1Down:connect(function() Position(v) end)
end
if (v.Name:sub(2, 2) == "A" and #v.Name ~= 2) then
v.MouseButton1Down:connect(function() Angles(v) end)
end
while inUse == true do
wait()
select = game.Selection:Get()
if (#select > 1) then
for i, v in pairs(select) do
if (v:IsA("Model")) then
returnDescendants(v, true)
elseif (v:IsA("BasePart")) then
table.insert(xs, v.Position.X)
table.insert(ys, v.Position.Y)
table.insert(zs, v.Position.Z)
end
end
xVec = 0
yVec = 0
zVec = 0
for i, v in pairs(xs) do
xVec = xVec + v
end
for i, v in pairs(ys) do
yVec = yVec + v
end
for i, v in pairs(zs) do
zVec = zVec + v
end
cframegui.Frame.XP.Text = tostring(math.floor(1000 * (xVec / #xs)) / 1000)
cframegui.Frame.YP.Text = tostring(math.floor(1000 * (yVec / #ys)) / 1000)
cframegui.Frame.ZP.Text = tostring(math.floor(1000 * (zVec / #zs)) / 1000)
cframegui.Frame.XA.Text = ""
cframegui.Frame.YA.Text = ""
cframegui.Frame.ZA.Text = ""
xs = {}
ys = {}
zs = {}
end
if (#select == 0) then
cframegui.Frame.XP.Text = ""
cframegui.Frame.YP.Text = ""
cframegui.Frame.ZP.Text = ""
cframegui.Frame.XA.Text = ""
cframegui.Frame.YA.Text = ""
cframegui.Frame.ZA.Text = ""
end
if (#select == 1) then
if (select[1]:IsA("BasePart")) then
angX, angY, angZ = select[1].CFrame:toEulerAnglesXYZ()
cframegui.Frame.XP.Text = tostring(math.floor(1000 * select[1].Position.X) / 1000)
cframegui.Frame.YP.Text = tostring(math.floor(1000 * select[1].Position.Y) / 1000)
cframegui.Frame.ZP.Text = tostring(math.floor(1000 * select[1].Position.Z) / 1000)
cframegui.Frame.XA.Text = tostring(math.floor(10 * math.deg(angX)) / 10)
cframegui.Frame.YA.Text = tostring(math.floor(10 * math.deg(angY)) / 10)
cframegui.Frame.ZA.Text = tostring(math.floor(10 * math.deg(angZ)) / 10)
end
if (select[1]:IsA("Model")) then
returnDescendants(select[1], true)
xVec = 0
yVec = 0
zVec = 0
for i, v in pairs(xs) do
xVec = xVec + v
end
for i, v in pairs(ys) do
yVec = yVec + v
end
for i, v in pairs(zs) do
zVec = zVec + v
end
cframegui.Frame.XP.Text = tostring(math.floor(1000 * (xVec / #xs)) / 1000)
cframegui.Frame.YP.Text = tostring(math.floor(1000 * (yVec / #ys)) / 1000)
cframegui.Frame.ZP.Text = tostring(math.floor(1000 * (zVec / #zs)) / 1000)
cframegui.Frame.XA.Text = ""
cframegui.Frame.YA.Text = ""
cframegui.Frame.ZA.Text = ""
xs = {}
ys = {}
zs = {}
end
end
end
end
end
end

function turnOff()
cframebutton:SetActive(false)
cframegui:Remove()
inUse = false
end

function returnDescendants(model, vectors)
for i, v in pairs(model:GetChildren()) do
if (v:IsA("BasePart")) then
if (vectors == false) then
table.insert(modelchil, v)
elseif (vectors == true) then
table.insert(xs, v.Position.X)
table.insert(ys, v.Position.Y)
table.insert(zs, v.Position.Z)
end
else
returnDescendants(v)
end
end
end

function Position(button)
sel = game.Selection:Get()
vec = button.Name:sub(1, 1)
if (button.Name:sub(3, 3) == "M") then
posneg = -1
else
posneg = 1
end
num = button.Name:sub(4)
if (num == "3") then
factor = 1
elseif (num == "2") then
factor = 0.1
elseif (num == "1") then
factor = 0.01
end
for i = 1, #sel do
if (sel[i]:IsA("BasePart")) then
if (vec == "X") then
sel[i].CFrame = sel[i].CFrame + Vector3.new(posneg * factor, 0, 0)
end
if (vec == "Y") then
sel[i].CFrame = sel[i].CFrame + Vector3.new(0, posneg * factor, 0)
end
if (vec == "Z") then
sel[i].CFrame = sel[i].CFrame + Vector3.new(0, 0, posneg * factor)
end
end
if (sel[i]:IsA("Model")) then
returnDescendants(sel[i], false)
for i, v in pairs(modelchil) do
if (vec == "X") then
v.CFrame = v.CFrame + Vector3.new(posneg * factor, 0, 0)
end
if (vec == "Y") then
v.CFrame = v.CFrame + Vector3.new(0, posneg * factor, 0)
end
if (vec == "Z") then
v.CFrame = v.CFrame + Vector3.new(0, 0, posneg * factor)
end
end
modelchil = {}
end
end
end

function Angles(button)
sel = game.Selection:Get()
vec = button.Name:sub(1, 1)
if (button.Name:sub(3, 3) == "M") then
posneg = -1
else
posneg = 1
end
num = button.Name:sub(4)
if (num == "3") then
factor = 10
elseif (num == "2") then
factor = 5
elseif (num == "1") then
factor = 1
end
if (#sel == 1) then
if (vec == "X") then
sel[1].CFrame = sel[1].CFrame * CFrame.Angles(math.rad(posneg * factor), 0, 0)
end
if (vec == "Y") then
sel[1].CFrame = sel[1].CFrame * CFrame.Angles(0, math.rad(posneg * factor), 0)
end
if (vec == "Z") then
sel[1].CFrame = sel[1].CFrame * CFrame.Angles(0, 0, math.rad(posneg * factor))
end
end
end

cframebutton.Click:connect(turnOn)

load = true
print("Blockoo's CFrame Plugin Loaded Successfully!")
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
24 Sep 2011 07:11 PM
I forgot to add, it's *not* CFraming when I click a button
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
24 Sep 2011 07:14 PM
Put the script in a Lua file in a folder in the Plugins folder if you need more specifics. It does not require any image.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
24 Sep 2011 07:55 PM
Bump P:
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
24 Sep 2011 08:45 PM
Bump
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
24 Sep 2011 08:52 PM
Dis looks ugly. Where is the CFrame part, or the part you said that isn't working?

­<'+1 Post. Ujelly?'>
Report Abuse
brickbuilder74 is not online. brickbuilder74
Joined: 23 Jun 2008
Total Posts: 8810
24 Sep 2011 08:57 PM
I can simplify that SOOO much. I have a CFrame plugin that's like less than 100 lines.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
24 Sep 2011 09:07 PM
@brick
Mine is probably longer because you don't need a separate selection system for it...mine is based on the current selection of the grabbing tool in studio. Mine also will calculate the exact center position of a group of bricks if you have multiple selected at once.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
24 Sep 2011 09:15 PM
e.e
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
25 Sep 2011 11:47 AM
eee.eee
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image