Hello, I am making a game but I’m worried that if the player rejoins, they can redo the prompt, my question is, how could I battle that? I was thinking something to do with datastore but honestly don’t know where to start, I was wondering if you could give me some sources as I cant find any.
This prompt is where you can click a textbutton to do something, but I want it so they can do it every hour or so.
1 Like
Yes, you’d probably need to implement some DataStore if you’re wanting to prevent the player from re-do’ing the prompt again when they rejoin
You could probably add a BoolValue if the player has activated it or not, then disable/enable the prompt afterwards
2 Likes
Thank you for the responses, I’ll try them now.
You can use Tick() to save the time that they activated the prompt. Save that Tick() time to a datastore when they use it, then when they join, check if an hour has past. 1 hour is 3600 seconds, and Tick() is the amount of seconds since 1970, so check fi the current tick is 3600 seconds greater than the Tick() time that they activated the prompt.
1 Like
So what you could do is do a datastore, like what they are saying.
I have created a script where a datastore is not necessary, but it will only exist for that specific server, therefore if they joined a new server, the current data would not be available from the previous server. However it they rejoined the same server, you could do this:
local playertable = {}
function check(player)
for i,v in pairs(playertable) do
if v == player then
return true
else
return false
end
end
end
function addplayer(player)
table.insert(playertable, player)
wait(3600) --3600 seconds is 1 hour, in what u requested
for i,v in pairs(playertable) do
if v == player then
table.remove(playertable, i)
end
end
end
script.Parent.ClickDetector.MouseClick:Connect(function(click)
local checker = check(tostring(click))
if not checker then
addplayer(tostring(click))
-- then put in what u need to happen here
else
print("Already used!")
end
end)
Since you’re probably looking for a datastore, I gave you the resources needed, just tweak them with checking if they are in the datastore, etc.
1 Like
Thank you for the responses, I have made the script, thanks a lot guys. (Especially @MomentarilyGood for the code)