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
 

Need help with CFrame - Please check fast

Previous Thread :: Next Thread 
Kalze is not online. Kalze
Joined: 24 Jun 2009
Total Posts: 27
24 Dec 2012 06:34 PM
So, I want to the Backpack tool to work, when it
is placing an item, the item would be perfectly aligned and you could rotate it like with the grab tool (no tilt needed). However, the annoying lua strikes again and produces some errors.

The lua:
-- Line98 VV
function do_rotate(example, center, new)
if example:IsA("BasePart") then
example.CFrame = new:toWorldSpace(center:toObjectSpace(object.CFrame))
end
end


function onKeyDown(key, mouse)
if key == "r" then
local center = example.GetCFrame()
local rotated = center * CFrame.Angles(0, math.pi / 2, 0)

do_rotate(center, rotated, false)
on_mouse_move(mouse)
elseif key == "e" then
local player = TOOL.Parent.Parent
local pack = player:findFirstChild("Pack")
local pack_tab = pack:GetChildren()

for index, child in pairs(pack_tab) do
CURRENT = child
onButton1Down(mouse)
wait(0.1)
end

CURRENT = nil
elseif key == "q" then
removeExample()
CURRENT = nil
end

update()
end

-- Line 161 VV
function onSelected(mouse)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
mouse.Move:connect(function() onMouseMove(mouse) end)
mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)

local player = TOOL.Parent.Parent
local playerGui = player.PlayerGui

playerGui.ScreenGui.Other.Visible = true

update()
end
And the error:

02:33:27 - Players.Player1.Backpack.Backpack.LocalScript:100: attempt to index global 'example' (a nil value)
02:33:27 - Script "Players.Player1.Backpack.Backpack.LocalScript", Line 100 - global onKeyDown
02:33:27 - Script "Players.Player1.Backpack.Backpack.LocalScript", Line 164
02:33:27 - stack end
02:33:27 - Disconnected event because of exception
Report Abuse
Kalze is not online. Kalze
Joined: 24 Jun 2009
Total Posts: 27
24 Dec 2012 07:57 PM
As such, Im still waiting for a response..
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
24 Dec 2012 07:58 PM
local center = example.GetCFrame() -- You never defined example, and it's :GetModelCFrame()
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