You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Simply put, I want to make a stud counter in my game. I found a friend who made a game with a stud counter, but the scripts they gave me don’t seem to work. Please note that I am not angry at the friend, even pro devs make mistakes in the code sometimes -
What is the issue? Include screenshots / videos if possible!
I know pretty much nothing about scripting, I can read the script and it makes a little sense to me, but not much -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried asking my friend about it but they couldn’t do much to help. I have also tried searching yt and here up and down for any kind of stud counter, but it’s never what I want and/or doesnt work
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Just to be safe, I will be keeping my friend fully anonymous
-- How this works: The player must walk on the part for the studs to be counted in. Eg: If the speed is 30 make the wait time (0.030) --
local part = script.Parent
local canGet = true
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
if humanoid then
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player and canGet then
canGet = false
player.leaderstats.Studs.Value = player.leaderstats.Studs.Value + 1
wait(0.016)
canGet = true
end
end
end
part.Touched:Connect(onTouch)
--[[Savin'
Dem
Stats
--]]
game.Players.PlayerRemoving:connect(function(player)
local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")
local statstorage = player:FindFirstChild("leaderstats"):GetChildren()
for i = 1, #statstorage do
datastore:SetAsync(statstorage[i].Name, statstorage[i].Value)
print("saved data number "..i)
end
print("Stats successfully saved")
end)
--[[
Loadin'
Dem
Stats
--]]
game.Players.PlayerAdded:connect(function(player)
local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")
player:WaitForChild("leaderstats")
wait(1)
local stats = player:FindFirstChild("leaderstats"):GetChildren()
for i = 1, #stats do
stats[i].Value = datastore:GetAsync(stats[i].Name)
print("stat numba "..i.." has been found")
end
end)
Please note that I also want the stud counter to reset once the player leaves the game, so the second one might not even be needed
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.