Thank you very much!!! kind of got it working...if it is ok to ask another question....
I have a spring aswell in the game which I got from the tool box I need to do the same thing otherwise people will just take advantage of it bouncing everywhere lol...How do I implement the same thing into the spring??
I have tried another script what you guys suggested but it fails to work any ideas??
sorry for the noob questions its probably easy!!...
here is the code..
Tool = script.Parent
Handle = Tool:WaitForChild("Handle")
CoilSound = Handle:WaitForChild("CoilSound")
EqualizingForce = (236 / 1.2) -- amount of force required to levitate a mass
Gravity = 0.75 -- things float at > 1
GhostEffect = nil
MassCon1 = nil
MassCon2 = nil
function GetTotalMass(Parent)
local TotalMass = 0
local function RecursiveGetMass(Parent)
for i, v in pairs(Parent:GetChildren()) do
if v:IsA("BasePart") and (v.Position - Character:GetModelCFrame().p).magnitude < 10 then
if v.Name == "Handle" then
TotalMass = (TotalMass + (v:GetMass() * EqualizingForce * 1))
else
TotalMass = (TotalMass + (v:GetMass() * EqualizingForce * Gravity))
end
end
RecursiveGetMass(v)
end
end
RecursiveGetMass(Parent)
TotalMass = TotalMass * 1.125
return TotalMass
end
function OnMassChanged(child, character)
if GhostEffect and GhostEffect.Parent then
GhostEffect.force = Vector3.new(0, GetTotalMass(Character), 0)
end
end
function UpdateGhostState(Unequipped)
if Unequipped then
GhostEffect:Destroy()
GhostEffect = nil
MassCon1:disconnect()
MassCon2:disconnect()
else
if not GhostEffect then
GhostEffect = Instance.new("BodyForce")
GhostEffect.Name = "GravityCoilEffect"
GhostEffect.force = Vector3.new(0, GetTotalMass(Character), 0)
GhostEffect.Parent = Head
MassCon1 = Character.ChildAdded:connect(function(Child)
OnMassChanged(Child, Character)
end)
MassCon2 = Character.ChildRemoved:connect(function(Child)
OnMassChanged(Child, Character)
end)
end
end
end
function OnEquipped()
Character = Tool.Parent
Head = Character:FindFirstChild("Head")
if not Head or not Head.Parent then
return
end
CoilSound:Play()
UpdateGhostState(false)
end
function OnUnequipped()
UpdateGhostState(true)
end
Tool.Equipped:connect(OnEquipped)
Tool.Unequipped:connect(OnUnequipped)
1 comment
i mean you could use the delay function