Claim chest is broken

hello robloxians,
i made dialy chest system but when i’m trying to claim the chest is show me error.
here is the script of the chest:

local Values = script.Parent.Parent:WaitForChild("ValuesSettings")
local GroupID = 6615086
local TimeWait = 60*15

script.Parent.Touched:Connect(function(hit)
    if hit:IsInGroup(GroupID) then
        print("inside the group")
    end
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil and hit:IsInGroup(GroupID) and Values.CanClaim.Value == true then
        player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + Values.GiveCoins.Value
        Values.CanClaim.Value = false
        Values.Text.Value = "You have to wait."
        wait(TimeWait)
        Values.CanClaim.Value = true
        Values.Text.Value = "Members only."
    end
end)

and here is the error:

image
thanks you all for help,
REALINONOOBYT.

That is because you keep getting hit, not Player:

hit.Parent:FindFirstChild("Humanoid") ~= nil and hit:IsInGroup(GroupID)

Change this to:

hit.Parent:FindFirstChild("Humanoid") ~= nil and player:IsInGroup(GroupID)

i think i tried to do that but let me take a look.

is keep show me the same error.

Then your error is here:

hit:IsInGroup(GroupID)

Change this:

script.Parent.Touched:Connect(function(hit)
    if hit:IsInGroup(GroupID) then
        print("inside the group")
    end

To this:

 local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player:IsInGroup(GroupID) then
        print("inside the group")
    end
1 Like

thanks is works! have a good day. :smiley:

1 Like