BrickUser
|
  |
| Joined: 19 Dec 2011 |
| Total Posts: 21266 |
|
|
| 13 Jan 2015 03:03 PM |
I want to make the character move when he has no gravity.
local bin = script.Parent
local equalizingForce = 800 / 1.2 local gravity = .5
function animate(torso) local m = torso:FindFirstChild("Right Shoulder") if m ~= nil then m.C0 = CFrame.fromEulerAnglesXYZ(0, -1.57, 3.14) + Vector3.new(-1, -0.5, 0) end m = torso:FindFirstChild("Left Shoulder") if m ~= nil then m.C0 = CFrame.fromEulerAnglesXYZ(0, -4.71, 3.14) + Vector3.new(1, -0.5, 0) end m = torso:FindFirstChild("Left Hip") if m ~= nil then m.C0 = CFrame.fromEulerAnglesXYZ(0, -1.57, 3.14) + Vector3.new(-1, 1, 0) end m = torso:FindFirstChild("Right Hip") if m ~= nil then m.C0 = CFrame.fromEulerAnglesXYZ(0, -4.71, 3.14) + Vector3.new(1, 1, 0) end end
local debound = false
function recursiveGetMass(node) local m = 0 local c = node:GetChildren() for i = 1,#c do if c[i].className == "Part" then m = m + c[i]:GetMass() end m = m + recursiveGetMass(c[i]) end return m end
function onHit(hit) if hit.Parent ~= nil then local human = hit.Parent:FindFirstChild("Humanoid") if human ~= nil and debound == false then debound = true bin.BrickColor = BrickColor.new(21) bin.Size = Vector3.new(2, .4, 2) bin.CFrame = bin.Parent.Stand.CFrame + Vector3.new(0, .2, 0) local torso = hit.Parent:FindFirstChild("Torso") local head = hit.Parent:FindFirstChild("Head") if torso ~= nil and head ~= nil then local weld = torso:FindFirstChild("Neck") if weld ~= nil then weld.C0 = CFrame.fromEulerAnglesXYZ(1.57, 0, 0) + Vector3.new(0, -1, 0) animate(torso, head) local bf = Instance.new("BodyForce") bf.Parent = torso bf.force = Vector3.new(0, recursiveGetMass(hit.Parent) * equalizingForce * gravity, 0) bf.Name = "Gravity" local gyro = Instance.new("BodyGyro") gyro.cframe = CFrame.new(1, 0, 1) gyro.maxTorque = Vector3.new(4e+005, 0, 4e+005) gyro.Parent = torso local gp = script.Gamepad:clone() gp.Disabled = false gp.Parent = hit.Parent end end wait(3) debound = false bin.BrickColor = BrickColor.new(28) bin.Size = Vector3.new(2, .8, 2) bin.CFrame = bin.Parent.Stand.CFrame + Vector3.new(0, .4, 0) end end end
bin.Touched:connect(onHit)
|
|
|
| Report Abuse |
|
BrickUser
|
  |
| Joined: 19 Dec 2011 |
| Total Posts: 21266 |
|
|
| 13 Jan 2015 03:06 PM |
| I don't want the player to not move, I want the player to move instead. |
|
|
| Report Abuse |
|
BrickUser
|
  |
| Joined: 19 Dec 2011 |
| Total Posts: 21266 |
|
| |
|
| 13 Jan 2015 03:23 PM |
| Don't underestimate the average scripter, they go through a lot more problems scripting then you may think. |
|
|
| Report Abuse |
|