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

If player has item, then remove Powerup?

Hello,

I have an Powerup system, Players can buy those with points and it will add you that amount of "Number" there. Example Anti Gravity. If you buy it it will add +4 there. At first you're gravity is 100% and if you buy it will take -4% away always. My question is: If player has Gravity Coil in BackPack or in hand

if Player.Backpack:FindFirstChild('GravityCoil') or Player.Character:FindFirstChild('GravityCoil') then

Then how could I change the Powerup (Gravity) to 100%? If he doesn't have it anymore, then it goes back to where it was.

Power Up code:

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

I still need help with that. More code:

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)

Also, that

if Player.Backpack:FindFirstChild('GravityCoil') or Player.Character:FindFirstChild('GravityCoil') then

That one doesn't seem to work at all. I did if he has GravityCoil, then it will print("Has the item") but it didin't print it. Could someone help

1 answer

I still need help with that. More code:

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)

Also, that

if Player.Backpack:FindFirstChild('GravityCoil') or Player.Character:FindFirstChild('GravityCoil') then

That one doesn't seem to work at all. I did if he has GravityCoil, then it will print("Has the item") but it didin't print it. Could someone help

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