What is the best way of making a Tycoon Claiming system?

I’m a very new scripting, and I’m trying to make a little generic tycoon to get some experience with scripting. I have working droppers and stuff, but I can’t seem to properly reference the player. My claim door uses part.Touched:Connect() and references the player under game.Workspace, so I know which player touched it. But for leaderstats to work, I need a reference to the player under game.players, rather than game.workspace. I’ve tried using teams and string values, but I can’t seem to figure it out.

Am I going about this all wrong? Please advise.

2 Likes
part.Touched:Connect(function(hit)

if hit.Parent:FindFirstChild("Humanoid") then --check if it's a character (this is line 3)

print("Character touched this part!")

local plr = game.Players:FindFirstChild(hit.Parent.Name) --look for the player using the character name

if plr then --this is line 9

print("actual player found")

--plr now is a reference to the player that touched the part(NOT the character)

end

end
end)

Use plr to index(reference) the player(after the if statement on line 9) and hit.Parent for the character (after line 3).

If you have any questions or the code doesn’t work, reply, otherwise, if it’s what you are looking for, mark this post as the solution.

3 Likes