Click on tool event

hello and tried to make that when you click when you have the object in your hand you get no gravity but this code does not work does anyone know a better solution?

local Players = game:GetService(“Players”)

local localPlayer = Players.LocalPlayer
local backpack = localPlayer:WaitForChild(“Backpack”)

local tool = Instance.new(“Tool”)
tool.RequiresHandle = false
tool.CanBeDropped = false
tool.Parent = backpack

tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
if mouse.Target and mouse.Target.Parent then
mouse.Target.Gravity = .9
wait(7)
mouse.Target.Gravity = 8
end
end)
end)

Parts don’t have a gravity property. You might want to insert a BodyForce for an anti-grav

1 Like

this is a better code:

local Players = game:GetService(“Players”)

local localPlayer = Players.LocalPlayer
local backpack = localPlayer:WaitForChild(“Backpack”)

local tool = Instance.new(“Tool”)
tool.RequiresHandle = false
tool.CanBeDropped = false
tool.Parent = backpack
local mouse = localPlayer:GetMouse()

tool.Activated:Connect(function()
if mouse.Target and mouse.Target.Parent then
mouse.Target.Gravity = .9
wait(7)
mouse.Target.Gravity = 8
end
end)

and please, use grammar because I don’t know what are you trying to say.

and, parts doesn’t have Gravity.

1 Like

I don’t know what you mean. I hope this game is appropriate…