You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I have this script, but I want to change a bit that, but I don’t know how.
What is the issue? It works perfectly, but I want that it gives every 60 minutes 1 points when someone is touching a part (like if someone touching a part and give every 60 secs +1; and if someone stopped touched it, don’t give points).
What solutions have you tried so far? Did you look for solutions on the Developer Hub? Yeah, I found that script but not with parts.
game.Players.PlayerAdded:Connect(function(hit)
if hit then
hit.CharacterAdded:Wait()
if hit:GetRankInGroup(mygroup) >= 99 then
while wait(60) do
local leaderstats = hit.leaderstats
leaderstats.Points.Value += 1
end
end
end
end)
Example:
Player keep touching the part → Give every 60 secs 1 point;
Player stopped touching the part → Stop giving 1 point every 60 secs;
If player touched again the part, start give points again.
So, each second a player is “touching” the part, that player will be given 1 point?
If player gets far from the part or not “touching it” player wont get any point per second.
If player gets close/touch to part again, player gets in the loop of earning 1 point each second again.
?
I would go with a RunService on server side, iterating a table of players that are allowed to earn a point.
If the player still “near/touching” the part, then the player is true in the table, then the RunService function will add a point on a delta specified time.
When players are “far/lost touch” of the part, they get removed from the table that RunService is using to grant points.