local PartTouch = false
game.Workspace.Part.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if test == false then local keys = hit.leaderstats.keys keys.Value = keys.Value + 1 end end end)
but it says in output
leaderstats is not a valid member of MeshPart "Workspace.abdulw12.RightLowerLeg
The "hit" variable returns the part that touched the brick.
replace this:
hit.leaderstats.keys keys.Value = keys.Value + 1
with this:
game:GetService("Players"):GetPlayerFromCharacter(hit.Parent).leaderstats.keys keys.Value = keys.Value + 1
oh wait I forgor to explain ????????
the .Touched event returns the part that touched the brick.
hit.Parent is the Character if a player had touched the brick.
game:GetService("Players") is just a safer version of game.Players
:GetPlayerFromCharacter(hit.Parent) gets the actual player object parented to game.Players.
hope that helped!!