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: Please help

Previous Thread :: Next Thread 
DataCrysis is not online. DataCrysis
Joined: 15 Sep 2012
Total Posts: 2546
14 Jan 2014 03:54 PM
Before I make a request let me just say, I need this script for science fair, I have tried to code it over and over but I cant really understand lua, and in my school if you dont make a B or Higher you flunk, so I cannot stress how important it is that this script works.If you will help thank you.

TL;DR: Need script, might flunk.

Anyway I need a script that changes the game gravity when the brick is touched.
If you save me thank you and whatever you religion is many thanks in however you would say it.

~You Obviously Lick Onions~
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
14 Jan 2014 04:03 PM
Why did you pick a topic that you cant do e.e

Here's a hint
Use BodyForce
Use the :GetMass() method
And
236/1.2 ~ the constant g in ROBLOX.

We won't do it for you, otherwise it'll be our project, not yours. I'll give you this much plus the method below. You work out the rest.

function getParts(model)
for i, v in pairs(model:children()) do
if v:IsA("Model") then
getParts(model)
elseif v:IsA("BasePart") then
--Enter in BodyForce here
end
end
end
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
14 Jan 2014 04:03 PM
*function, not method.
Report Abuse
DataCrysis is not online. DataCrysis
Joined: 15 Sep 2012
Total Posts: 2546
14 Jan 2014 04:12 PM
It was supposed to be a long term project and learning lua was part of it, I tried and tried but I cant understand it so I guess I'll hope google doesnt hate me and see if I can figure out what you gave me.

~You Obviously Lick Onions~
Report Abuse
DataCrysis is not online. DataCrysis
Joined: 15 Sep 2012
Total Posts: 2546
14 Jan 2014 04:35 PM
I have worked and tinkered and got this:
local myPart = Instance.new("Part")
myPart.Parent = game.Workspace
myPart.Size = Vector3.new(4, 1.2, 2)
myPart.Anchored = true
local myMass = myPart:GetMass()
print("My part's mass is " .. myMass)
function getParts(model)
for i, v in pairs(model:children()) do
if v:IsA("Model") then
getParts(model)
elseif v:IsA("BasePart") then
script.Parent.BodyForce.force = Vector3.new(0, 5000000, 0)
end
end
end

does it all look good?


~You Obviously Lick Onions~
Report Abuse
DataCrysis is not online. DataCrysis
Joined: 15 Sep 2012
Total Posts: 2546
14 Jan 2014 04:43 PM
please....I cannot fail this....

~You Obviously Lick Onions~
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
14 Jan 2014 04:52 PM
Except for the fact that there is no .Touched event and you never called the function... ya.
Report Abuse
DataCrysis is not online. DataCrysis
Joined: 15 Sep 2012
Total Posts: 2546
14 Jan 2014 05:03 PM
local myPart = Instance.new("Part")
myPart.Parent = game.Workspace
myPart.Size = Vector3.new(4, 1.2, 2)
myPart.Anchored = true
local myMass = myPart:GetMass()
print("My part's mass is " .. myMass)
function getParts(model)
for i, v in pairs(model:children()) do
if v:IsA("Model") then
getParts(model)
elseif v:IsA("BasePart") then
script.Parent.BodyForce.force = Vector3.new(0, 5000000, 0)
Workspace.part.Touched:Connect(function(getParts)
end
end
end

this good?
or even getting there? again lua doesnt really click with me....

~You Obviously Lick Onions~
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
14 Jan 2014 05:07 PM
I'd make a very very bad teacher e.e
local gravfactor = .5 --50% of gravity
local myPart = Instance.new("Part")
myPart.Parent = game.Workspace
myPart.Size = Vector3.new(4, 1.2, 2)
myPart.Anchored = true
local myMass = myPart:GetMass()
print("My part's mass is " .. myMass)

function getParts(model)
for i, v in pairs(model:children()) do
if v:IsA("Model") then
getParts(model)
elseif v:IsA("BasePart") then
if v:FindFirstChild("BodyForce") then v.BodyForce:Destroy() end
local ff = Instance.new("BodyForce",v)
ff.force = Vector3.new(0, v:GetMass()*236/1.2*gravfactor, 0)
end
end
end

Workspace.part.Touched:Connect(function(hit)
if hit and hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
getParts(workspace)
end
end)
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
14 Jan 2014 05:10 PM
VoidShredder, please don't use 236/1.2 for g.
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
14 Jan 2014 05:10 PM
@Absurd idk the real value for it ;-;
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
14 Jan 2014 05:12 PM
196.2 approximately.
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
14 Jan 2014 05:12 PM
So...
9.81(or the irl version of g)*200 e.e?
Report Abuse
DataCrysis is not online. DataCrysis
Joined: 15 Sep 2012
Total Posts: 2546
14 Jan 2014 05:13 PM
ty so much now I wont have to flunk.

~You Obviously Lick Onions~
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
14 Jan 2014 05:13 PM
*20
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
14 Jan 2014 05:14 PM
Yes. Based on the fact that 20 studs = 1 meter, as I recall.
Report Abuse
DataCrysis is not online. DataCrysis
Joined: 15 Sep 2012
Total Posts: 2546
14 Jan 2014 05:18 PM
So wait what is the gravity value?

~You Obviously Lick Onions~
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
14 Jan 2014 05:19 PM
acceleration due to gravity = 9.81*20
change 236/1.2 into 9.81*20
Report Abuse
DataCrysis is not online. DataCrysis
Joined: 15 Sep 2012
Total Posts: 2546
14 Jan 2014 05:22 PM
done ty :)

~You Obviously Lick Onions~
Report Abuse
DataCrysis is not online. DataCrysis
Joined: 15 Sep 2012
Total Posts: 2546
14 Jan 2014 05:24 PM
So just to be clear this changes the gravity if someone touches the brick right? or am I understanding wrong?

~You Obviously Lick Onions~
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
14 Jan 2014 05:53 PM
yup... sorta
Report Abuse
DataCrysis is not online. DataCrysis
Joined: 15 Sep 2012
Total Posts: 2546
14 Jan 2014 06:02 PM
It's not working for me, not really sure why I will continue trying to fix it I guess.....

~You Obviously Lick Onions~
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
14 Jan 2014 06:15 PM
local gravfactor = .5 --50% of gravity
local myPart = Instance.new("Part")
myPart.Parent = game.Workspace
myPart.Size = Vector3.new(4, 1.2, 2)
myPart.Anchored = true
local myMass = myPart:GetMass()
print("My part's mass is " .. myMass)

function getParts(model)
for i, v in pairs(model:children()) do
if v:IsA("Model") then
getParts(model)
elseif v:IsA("BasePart") then
if v:FindFirstChild("BodyForce") then v.BodyForce:Destroy() end
local ff = Instance.new("BodyForce",v)
ff.force = Vector3.new(0, v:GetMass()*236/1.2*gravfactor, 0)
end
end
end

script.Parent.Touched:connect(function(hit)
if hit and hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
getParts(workspace)
end
end)

Try it now?
Report Abuse
DataCrysis is not online. DataCrysis
Joined: 15 Sep 2012
Total Posts: 2546
14 Jan 2014 06:26 PM
errr still not working :/ maybe instead of it creating a new brick it could trigger a
change in the gravity when you touch a brick?

~You Obviously Lick Onions~
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
14 Jan 2014 06:27 PM
... Omg I didnt even notice the first part that was there...
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