Trying to find out a tier value and giving someone the amount of points of that tier value

I’ve been trying to make something where the player receives the amount of points the tier value is

e.g.
tier = 10 points receiving after win = 10

ive been trying to do for loops
please help me if you can:

code:

local workspace = game.Workspace
local plr = game.Players.LocalPlayer
local humanoid = plr.Character:WaitForChild("Humanoid")


for model, v in pairs(workspace:GetChildren()) do
	if v:IsA("Model") and v.Name == "Obby" then
		for tier, v in pairs(model:GetChildren()) do
			v.win.Touched:Connect(function(hit)
				if hit.Parent == plr then
					if tonumber(v.Tier.Value) then
						plr.leaderstats.Tokens.Value += v.Tier.Value
						v.kill.Touched:Connect(function(hit)
							if hit.Parent == humanoid then
								humanoid.Health = 0
							end
						end)
					end
				end
			end)
		end
	end
end

This is basically checking if the Character Model is equal to the Player Object, which is not valid to your conditional check

To fix it, try changing that to:

if game.Players:GetPlayerFromCharacter(hit.Parent) == plr then
1 Like

so u r saying that every line of code is fine but the

if hit.Parent == plr then

is it that im using the index or values wrong in the for loop???

pls reply

Index iterates the number of things there are in the table, or in this instance your tier, v pairs

Although you aren’t doing it in a specific order, might wanna use ipairs instead?