So basically, I am trying to make a counter that goes up for every time someone falls into a trigger. I’m not talking about it being stored by the player, I’m talking about this being stored by the game. Would anyone know how to do this?
Example:
So basically, I am trying to make a counter that goes up for every time someone falls into a trigger. I’m not talking about it being stored by the player, I’m talking about this being stored by the game. Would anyone know how to do this?
Example:
You could check when a player dies, add to that text + 1 [make sure it’s a number in your text]
For e.g,
you could use Humanoid.Died()
event to tell when the player died.
Sorry, but how would I do that?
You could use an IntValue
that goes up when a player falls into the trigger.
For the trigger, you would probably use something like a .Touched
event, and when that event fires you set the IntValue
to itself + 1.
Here, a brief/simple example :
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function()
script.Parent.Text = script.Parent.Text + 1
end)
end)
end)
Make sure your text is 0 or any number
They’re trying to make a variable, an IntValue
would be easier than constantly getting tonumber(TextLabel.Text)
.
You dont have to tonumber that text as long as that text is a number
But generally - yes, it’s preferred to use a global value
You would if you needed to get the number, if you didn’t do that you would get a string which would error scripts that used it.
The script here works perfectly
If you want to do something with that number, then you’d have to tonumber
the text
simple use values they are ga- EXPERIENCE wide
No, I meant like they store from every single experience open
by that you mean every server of your experience right?
I think you want to use DataStoreService:GetDataStore(“x”), which will return a DataStore, and then use IncrementAsync to increment the value and GetAsync to retrieve the current value.
Can you show me an example? I’m kind of new at this.
You just need to put a _G. before your variable
for example
_G.fallen = 0
This variable can be accessed from any script anywhere on the server
everytime player falls do _G.fallen += 1
local DS = game:GetService("DataStoreService"):GetGlobalDataStore()
local VarName = "Players Fell"
local CurrentVal = 0
local AddVal = 0
local function Add()
local success, msg = pcall(function()
CurrentVal = DS:IncrementAsync(VarName, AddVal)
end)
if not success then print("----", msg) end
if success then AddVal = 0 end
end
while wait(10) do
Add()
end
^^ Why does Roblox do this? My post isn’t empty…
So where would I put this script inside of