Alright, made a tool and when you press down it makes you fly basically in the direction that your Mouse is pointing alright so I did all the script and it works fine... However the second part of the script with the Deactivated event for the tool does not work the first time and I have kind of an idea on as to why it won't work but, I can't fix it maybe it's a Roblox bug? But I am not sure anyways so I made a test tool and made a Activated event and made it so that when you activate the tool while it's being activated it prints("FirstPhase") then when it's deactivated it prints("SecondComplete") and after it deactivated it printed "FirstPhase" again for some reason.... And here is the script for my fly tool which won't remove the BodyGyro and BodyPosition in the beginning, but the second time I press down it removes the ones that are created for the second time but, won't remove the first ones that were created... Is this a Roblox bug? If so then how may I deal with it.... The script is under a Tool inside of StarterPack it's a LocalScript

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local tool = script.Parent
local deb = false

tool.Activated:connect(function()
	if deb == false then
	deb = true
	local char = player.Character
	local bg = Instance.new("BodyGyro")
	local bv = Instance.new("BodyVelocity")
	bg.Name = "FlyGyro"
	bv.Name = "FlyVelocity"
	while deb == true do
	wait()
	bg.D = 100
	local pos = mouse.Hit.p
	local torso = player.Character:WaitForChild("Torso")
	bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
	bg.cframe = CFrame.new(torso.Position,pos)
	bv.maxForce = Vector3.new(math.huge,math.huge,math.huge)
	bv.velocity = torso.CFrame.lookVector * 50
	bg.Parent = torso
	bv.Parent = torso
	end
	end
end)

tool.Deactivated:connect(function()
	if deb == true then
	deb = false
	local torso = player.Character:WaitForChild("Torso")
	local bg = torso:findFirstChild("BodyGyro")
	local bv = torso:findFirstChild("BodyVelocity")
	local children = torso:GetChildren()
	for _, v in pairs(children) do
		if v:IsA("BodyVelocity") or v:IsA("BodyGyro") then
			v:remove()
		end
		end
	end
end)

This is very crucial for me I hope someone can help me out with this. Thank you!

1 comment

0

Im having this same problem. What was the solution?