Hello,
In-Game I have an item called "Gravity Coil" so you can jump higher. There's also ability to "Upgrade" Power Up. There's possibility to upgrade Gravity as well. So If your Gravity is upgraded to Maximum (From 100% to 60%) and you use Gravity Coil same time, you will "Fly" forever to Sky. You can upgrade Gravity each time 4% until it goes to 60%. My problem is, I've tried to make a script which will set it back to 100% if you have Gravity Coil in Backpack or In-Hand, but it didn't worked out. Is there someone who can help me to make it? Thanks! Gravity Button & Adder
local GravityUp = Instance.new("TextButton") GravityUp.BackgroundColor3 = Color3.new(0.9, 0.9, 0.9) GravityUp.BackgroundTransparency = 0.2 GravityUp.Position = UDim2.new(0, 0, 1, -130) GravityUp.Size = UDim2.new(0, 155, 0, 20) GravityUp.Text = "Gravity -4% for 150 points (" .. 100 - Powerups[Player]["AntiGrav"] .. "%)" GravityUp.Parent = Gui GravityUp.MouseButton1Click:connect(function() if Powerups[Player]["AntiGrav"] < 60 then if Points.Value >= 150 then Points.Value = Points.Value - 150 Powerups[Player]["AntiGrav"] = Powerups[Player]["AntiGrav"] + 4 GravityUp.Text = "Gravity -4% for 150 points (" .. 100 - Powerups[Player]["AntiGrav"] .. "%)" UpdatePowerUps(Player) end if Powerups[Player]["AntiGrav"] >= 60 then GravityUp.Text = "Gravity Minimum (40%)"
Gravity Base:
pcall(function() local Torso = Player.Character.Humanoid.Torso local AntiGrav = Torso:FindFirstChild("BodyForce") or Instance.new("BodyForce") AntiGrav.force = Vector3.new(0, GetMass(Player.Character) * 196.2 * Powerups[Player].AntiGrav / 100, 0) AntiGrav.Parent = Torso end) end
Well, I recommend spacing out your code, or else it's a bit tricky for us to read. Where do you want to check if they have it equipped in their hand? To save some time, I'll write an example code which you can use:
if player.Character:FindFirstChild("Tool") then -- stuff end if player.Backpack:findFirstChild("Tool") then -- stuff end
Questions? Comment!