Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't this Gravity Coil work? Blah

I got a gravity coil from the tool box but when I tested it it didn't work. Can someone tell me what to fix on the script.

-------- OMG HAX

r = game:service("RunService")


Tool = script.Parent

local equalizingForce = 236 / 1.2 -- amount of force required to levitate a mass
local gravity = .999999999999 -- things float at > 1

local ghostEffect = nil
local massCon1 = nil
local massCon2 = nil

function recursiveGetLift(node)
	local m = 0
	local c = node:GetChildren()
	for i=1,#c do
		if c[i].className == "Part" then
			if c[i].Name == "Handle" then
				m = m + (c[i]:GetMass() * equalizingForce * 1) -- hack that makes hats weightless, so different hats don't change your jump height
			else
				m = m + (c[i]:GetMass() * equalizingForce * gravity)
			end
		end
		m = m + recursiveGetLift(c[i])
	end
	return m
end


function onMassChanged(child, char)
	print("Mass changed:" .. child.Name .. "    " .. char.Name)
	if (ghostEffect ~= nil) then
		ghostEffect.force = Vector3.new(0, recursiveGetLift(char) ,0)
	end
end



function UpdateGhostState(isUnequipping)

	if isUnequipping == true then
		ghostEffect:Remove()
		ghostEffect = nil
		massCon1:disconnect()
		massCon2:disconnect()
	else
		if ghostEffect == nil then
			local char = Tool.Parent
			if char == nil then return end
			ghostEffect = Instance.new("BodyForce")
			ghostEffect.Name = "GravityCoilEffect"
			ghostEffect.force = Vector3.new(0, recursiveGetLift(char) ,0)
			ghostEffect.Parent = char.Head
			ghostChar = char
			massCon1 = char.ChildAdded:connect(function(child)  onMassChanged(child, char) end)
			massCon2 = char.ChildRemoved:connect(function(child)  onMassChanged(child, char) end)
		end
	end
	

end



function onEquipped()
	Tool.Handle.CoilSound:Play()
	UpdateGhostState(false)
end

function onUnequipped()
	UpdateGhostState(true)
end


script.Parent.Equipped:connect(onEquipped)
script.Parent.Unequipped:connect(onUnequipped)

5 comments

0

remove the false on line 69? maybe

0

^ That's not the problem; as shown in his script, it's used to enable/disable the "ghost state".

0

Make your own tools.. Ask the tool's creator to where you need to put the tool. Maybe it's old and some functions are deprecated. And what the Hell is that ,,OMG HAX'' in line 1?? ????

0

:D

0

IDK the creator put "OMG HAX" there

1 answer

First, I recommend you to make your own tools. Don't always believe that every thing you get from toolbox will work.. This script starts with "OMG HAX", and that's weird too.. Please give us output errors, if there is/are, and it's not always the script's fault, it can be you too. Where is the script located? Where is the tool located? Also, this line:

r = game:service("RunService")

should be this:

r = game:GetService("RunService")

This tool may be old. Next time give more information!

This discussion is preserved as it was. New answers, comments, and votes are closed.