hello everyone, the :IsDescendantOf statement is returning false what is the fix of this?
yeah so i am trying to make the button get 1$ countinously but i am getting false statement
local playerService = game:GetService("Players")
local button = script.Parent.redbutton
local function onHumanoidTouched(humanoid)
local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
if player then
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local cash = leaderstats:FindFirstChild("Cash")
if cash then
local pass2x = player.ButtonsFolder.Cash2x.Value
local pass3x = player.ButtonsFolder.Cash3x.Value
local pass5x = player.ButtonsFolder.Cash5x.Value
if humanoid:IsDescendantOf(button) then
print("true")
else
print("false")
end
while humanoid:IsDescendantOf(button) do
print("done5")
cash.Value = cash.Value + 1 -- add $1 continuously
wait(1)
end
end
end
end
end
button.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
onHumanoidTouched(humanoid)
end
end)