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: Motor Turning

Previous Thread :: Next Thread 
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
25 Apr 2013 03:22 PM
So I've scripted my basic little RoKart like morph, but now I'm wanting to make the wheels rotate when I'm waking... So what would I need to add to my script in order to do that?

--Made by GuestCapone, RoKart morph. This goes into a LocalScript IN a HopperBin.
local player = game:GetService('Players').LocalPlayer
local hopper = script.Parent
local Mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local char = player.Character


repeat wait() until game.Players.LocalPlayer
wait(.2) -- lets the script load, try not to touch this.
player.Character.Torso.Anchored = true -- Forces the Player to select the tool to play.



--Equipped
hopper.Selected:connect(function(mouse)
player.Character.Torso.Anchored = false -- So you can move.
print("Equipped")
player.Character["Left Arm"]:Remove()
player.Character["Right Arm"]:Remove()
player.Character["Left Leg"]:Remove()
player.Character["Right Leg"]:Remove()
player.Character.Animate:Remove()
player.Character.RobloxTeam:Remove()
player.Character.Sound:Remove()
run_debounce = false

bf = Instance.new("BodyForce");
bf.force = Vector3.new(0,-2000,0);
bf.Parent = player.Character.Torso

frame = Instance.new('Part')
frame.Size = Vector3.new(2, 1,5)
frame.Name = "Frame"
frame.FormFactor = 0
frame.Parent = player.Character
local weld = Instance.new("Weld")
weld.Part0 = player.Character:FindFirstChild("Torso")
weld.Part1 = frame
weld.C1 = weld.C1 * CFrame.new(0, 0, .8) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
weld.Parent = player.Character:FindFirstChild("Torso")

engine = Instance.new('Part')
engine.Size = Vector3.new(2, 1, 1)
engine.Name = "Engine"
engine.Parent = player.Character
engmesh = Instance.new("SpecialMesh")
engmesh.Parent = engine
engmesh.MeshType = "Torso"
local weld = Instance.new("Weld")
weld.Part0 = player.Character:FindFirstChild("Torso")
weld.Part1 = engine
weld.C1 = weld.C1 * CFrame.new(0, -1.2, -2) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
weld.Parent = player.Character:FindFirstChild("Torso")

frontleftwheel = Instance.new('Part')
frontleftwheel.Size = Vector3.new(2, 2, 2)
frontleftwheel.Name = "FrontLeftWheel"
frontleftwheel.Parent = player.Character
frontleftwheel.Shape = 2
local weld = Instance.new("Motor")
weld.Part0 = player.Character:FindFirstChild("Torso")
weld.Part1 = frontleftwheel
weld.C1 = weld.C1 * CFrame.new(2, .3, 2) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
weld.Parent = player.Character:FindFirstChild("Torso")

frontrightwheel = Instance.new('Part')
frontrightwheel.Size = Vector3.new(2, 2, 2)
frontrightwheel.Name = "FrontRightWheel"
frontrightwheel.Parent = player.Character
frontrightwheel.Shape = 2
local weld = Instance.new("Motor")
weld.Part0 = player.Character:FindFirstChild("Torso")
weld.Part1 = frontrightwheel
weld.C1 = weld.C1 * CFrame.new(-2, .3, 2) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
weld.Parent = player.Character:FindFirstChild("Torso")

backleftwheel = Instance.new('Part')
backleftwheel.Size = Vector3.new(2, 2, 2)
backleftwheel.Name = "BacktLeftWheel"
backleftwheel.Parent = player.Character
backleftwheel.Shape = 2
local weld = Instance.new("Motor")
weld.Part0 = player.Character:FindFirstChild("Torso")
weld.Part1 = backleftwheel
weld.C1 = weld.C1 * CFrame.new(2, .3, -2.2) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
weld.Parent = player.Character:FindFirstChild("Torso")

backrightwheel = Instance.new('Part')
backrightwheel.Size = Vector3.new(2, 2, 2)
backrightwheel.Name = "BackRightWheel"
backrightwheel.Parent = player.Character
backrightwheel.Shape = 2
local weld = Instance.new("Motor")
weld.Part0 = player.Character:FindFirstChild("Torso")
weld.Part1 = backrightwheel
weld.C1 = weld.C1 * CFrame.new(-2, .3, -2.2) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
weld.Parent = player.Character:FindFirstChild("Torso")
end)

--Unequipped
hopper.Deselected:connect(function()
player.Character.Humanoid:BreakJoints() -- This doesn't work?
player.Character.Torso.Anchored = true -- Anti movement system.
end)

player.Character.Humanoid.Died:connect(function()
--St00f goes here
end)

Im guessing I'll need a Humanoid.running connection line, but other then that I don't know what else I'll need.
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
25 Apr 2013 03:40 PM
Bump
Report Abuse
ToboboT is not online. ToboboT
Joined: 25 Jun 2011
Total Posts: 2385
25 Apr 2013 03:49 PM
It is a bit long, maybe put spilt it up into parts you know work and don't work.
Report Abuse
djwolf95 is not online. djwolf95
Joined: 06 Sep 2008
Total Posts: 89
25 Apr 2013 03:52 PM
I haven't studied the use of motors yet, but from what I have seen they need a lot of 'math' equations that deal with maxforce n' what not so that the motor doesn't break itself or the parts it animates on accident while the character moves around a game.
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
25 Apr 2013 04:20 PM
@ ToboboT the script is pretty much the same thing throught it...
It works like so :

Make part
make weld
make another part
make motor
etc

@Djwolf95
Know of any opensource places and/or models that would help with show how to do that?
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
25 Apr 2013 05:52 PM
Help?
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
25 Apr 2013 06:01 PM
...
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
25 Apr 2013 07:58 PM
-_-

Really... No help..
I've been to the wiki... There is NO help their, that's why I'm here...

:l
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
25 Apr 2013 08:57 PM
give the motor some thrust and change the angular velo

player.Character.Humanoid:BreakJoints()

player.Character:BreakJoints()
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
26 Apr 2013 02:11 AM
Erm, how I do that? DesiredAngle and MaxVelocity???
Report Abuse
djwolf95 is not online. djwolf95
Joined: 06 Sep 2008
Total Posts: 89
26 Apr 2013 02:29 AM
I found a script builder script a while back that had animated parts on it, they were wings so a considerable bit more complex, do you want me to try and pick out somethings it has that yours does not?
Report Abuse
sycips is not online. sycips
Joined: 21 Mar 2011
Total Posts: 1368
26 Apr 2013 04:47 AM
motorweld = YourMotorWeld
number = 0
running = false

Humanoid.Running:connect(function(speed)
running = speed > 0
end)

while wait() do
if running then
motorweld:SetDesiredAngle(number)
number = number + math.pi/2
end
end

Something like this?

Enjoy :)

~sycips~
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
26 Apr 2013 09:10 AM
I think so...

Erm, can someone see what I did incorrect with my welding? Upon selecting this tool, my player is stuck and the wheels aren't getting CFramed... Can someone tell me why? (Yes you have to run the script in order to know whats going on)

--Made by GuestCapone, RoKart morph. This goes into a LocalScript IN a HopperBin.
local player = game:GetService('Players').LocalPlayer
local hopper = script.Parent
local Mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local char = player.Character
local number = 0
local running = false


repeat wait() until game.Players.LocalPlayer
wait(.2) -- lets the script load, try not to touch this.
player.Character.Torso.Anchored = true -- Forces the Player to select the tool to play.



--Equipped
hopper.Selected:connect(function(mouse)
player.Character.Torso.Anchored = false -- So you can move.
print("Equipped")
player.Character["Left Arm"]:Remove()
player.Character["Right Arm"]:Remove()
player.Character["Left Leg"]:Remove()
player.Character["Right Leg"]:Remove()
player.Character.Animate:Remove()
player.Character.RobloxTeam:Remove()
player.Character.Sound:Remove()

bf = Instance.new("BodyForce");
bf.force = Vector3.new(0,-2000,0);
bf.Parent = player.Character.Torso

frame = Instance.new('Part')
frame.Size = Vector3.new(2, 1,5)
frame.Name = "Frame"
frame.FormFactor = 0
frame.Parent = player.Character
local weld = Instance.new("Weld")
weld.Part0 = player.Character:FindFirstChild("Torso")
weld.Part1 = frame
weld.C1 = weld.C1 * CFrame.new(0, 0, .8) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
weld.Parent = player.Character:FindFirstChild("Torso")

engine = Instance.new('Part')
engine.Size = Vector3.new(2, 1, 1)
engine.Name = "Engine"
engine.Parent = player.Character
engmesh = Instance.new("SpecialMesh")
engmesh.Parent = engine
engmesh.MeshType = "Torso"
local weld = Instance.new("Weld")
weld.Part0 = player.Character:FindFirstChild("Torso")
weld.Part1 = engine
weld.C1 = weld.C1 * CFrame.new(0, -1.2, -2) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
weld.Parent = player.Character:FindFirstChild("Torso")


frontleftwheel = Instance.new('Part')
frontleftwheel.Size = Vector3.new(2, 2, 2)
frontleftwheel.Name = "FrontLeftWheel"
frontleftwheel.Parent = player.Character
frontleftwheel.Shape = 2
frontleftmotor = Instance.new("Motor")
frontleftmotor.Part0 = player.Character:FindFirstChild("Torso")
frontleftmotor.Part1 = frontleftwheel
frontleftmotor.C1 = weld.C1 * CFrame.new(2, .3, 2) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
frontleftmotor.Parent = frame
frontleftmotor.Name = "frontleftmotor"

frontrightwheel = Instance.new('Part')
frontrightwheel.Size = Vector3.new(2, 2, 2)
frontrightwheel.Name = "FrontRightWheel"
frontrightwheel.Parent = player.Character
frontrightwheel.Shape = 2
frontrightmotor = Instance.new("Motor")
frontrightmotor.Part0 = player.Character:FindFirstChild("Torso")
frontrightmotor.Part1 = frontrightwheel
frontrightmotor.C1 = weld.C1 * CFrame.new(-2, .3, 2) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
frontrightmotor.Parent = frame
frontrightmotor.Name = "frontrightmotor"

backleftwheel = Instance.new('Part')
backleftwheel.Size = Vector3.new(2, 2, 2)
backleftwheel.Name = "BacktLeftWheel"
backleftwheel.Parent = player.Character
backleftwheel.Shape = 2
backleftmotor = Instance.new("Motor")
backleftmotor.Part0 = player.Character:FindFirstChild("Torso")
backleftmotor.Part1 = backleftwheel
backleftmotor.C1 = weld.C1 * CFrame.new(2, .3, -2.2) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
backleftmotor.Parent = frame
backleftmotor.Name = "backleftmotor"

backrightwheel = Instance.new('Part')
backrightwheel.Size = Vector3.new(2, 2, 2)
backrightwheel.Name = "BackRightWheel"
backrightwheel.Parent = player.Character
backrightwheel.Shape = 2
backrighmotor = Instance.new("Motor")
backrighmotor.Part0 = player.Character:FindFirstChild("Torso")
backrighmotor.Part1 = backrightwheel
backrighmotor.C1 = weld.C1 * CFrame.new(-2, .3, -2.2) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
backrighmotor.Parent = frame
backrighmotor.Name = "backrighmotor"




player.Character.Humanoid.Running:connect(function(speed)
running = speed > 0
end)

-----------------------------------------------------------------
while wait() do
if running then
print("spinning wheels")
frontleftwheel:SetDesiredAngle(number)
frontrightwheel:SetDesiredAngle(number)
backleftwheel:SetDesiredAngle(number)
rame.backrightwheel:SetDesiredAngle(number)
number = number + math.pi/2
end
end
-----------------------------------------------------------------
end)
--Unequipped
hopper.Deselected:connect(function()
--player.Character:BreakJoints()
player.Character.Torso.Anchored = true -- Anti movement system.
end)

player.Character.Humanoid.Died:connect(function()

end)

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