Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I get this script to work once per player?

Asked by 10 years ago

Ok so I made a script where you touch a part and you get a Point in the leaderboard. I called the Points Stars. How do I get this script to work once for each player. For example a guy gets the star and in the leaderboards it says he has 1 star. Then he goes up to it again and he doesn't get another star from that one because he already has it. Please help I kept trying but when I did it just didn't work! :(

01local ting = 0 --debouncer
02 
03function onTouched(hit)
04 
05    if ting == 0 then --debounce check
06    ting = 1 --activate debounce
07    check = hit.Parent:FindFirstChild("Humanoid") --Find the human that touched the button
08    player = hit.Parent
09 
10    if check ~= nil then --If a human is found, then
11 
12        local user = game.Players:GetPlayerFromCharacter(hit.Parent) --get player from touching human
13        local stats = user:findFirstChild("leaderstats") --Find moneyholder
14 
15        if stats ~= nil then --If moneyholder exists then
View all 32 lines...
0
You could always add a value to the players, then if they touch it, it makes it true. Or something.. Tempestatem 884 — 10y
0
Hmm but if I make the star insert a value there will be lots of values in your character and it could glitch. I want it to go by the player's name who touched it and then if they touch it again it just adds 0. flamenathan327 20 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

Add a value to the players, example;

If you add a value to the players, and they touch the 'Star', it makes it true.

0
Oh and also I found a glitch where you get lots of stars when touching the part that supposed to give you one. I even made it kill too but that didn't help. Please help me! flamenathan327 20 — 10y
Ad

Answer this question