Touch to get cash not working!

Is the leaderboard script working?

Let me send the output it says in the output bar.

Replace your leaderstat script with this:

game.Players.PlayerAdded:Connect(function(player)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local cash = Instance.new("IntValue")
	cash.Name = "Cash"
	cash.Parent = leaderstats

end)

Then try using my other script, then please send me the results.

[09:48:22.255 - Script ‘ServerScriptService.Leaderboard’, Line 3]

I’m trying that out now, need to go to class now though.

Sadly it is still not working, are there any properties I might need to change?

It’s not working because you are using a Lowercase c instead of a Uppercase C

He already changed that, as you can tell from above.

It looks like you are doing it wrong.

Here’s how you do it.

Note: you will have to add a remote event, put it in replicatedstorage, and name it “OnPartTouched”

1st script server script in server script storage.

local replicatedstorage = game:GetService("ReplicatedStorage")
local TouchedEvent = replicatedstorage:WaitForChild("OnPartTouched")

game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("leaderstats"); leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local Cash = Instance.new("IntValue"); Cash.Name = "Cash"
Cash.Parent = leaderstats



local Time = Instance.new("IntValue");  TimePlayed.Parent = player 
Time.Name = "TimePlayed"
-- this value above will not be showed, do not worry about it

Time.Value = os.time()
end)

TouchedEvent.OnServerEvent:Connect(function(player)

local leaderstats = player:WaitForChild("leaderstats")
local Cash = leaderstats:WaitForChild("Cash")
local TimePlayed = player:WaitForChild("TimePlayed")

if os.time() >= TimePlayed.Value + 3600 then
Cash = Cash + 100
TimePlayed.Value = os.time() 

end

end)

client script below

local event = game:GetService("ReplicatedStorage"):WaitForChild("OnPartTouched")

local part =  --object--

part.Touched:Connect(function(hit)
local db = false
if hit.Parent:FindFirstChild("Humanoid") and not db then
event:FireServer()
debounce = true
wait(1)
debounce = false
end

sorry if i did not get the os.time() part right, haven’t really studied it.

Where does the first one go? Wording is confusing to me, you said 1st script server script in server script storage. So server script service?

no, server script is not a service, when I mean server script I mean like a regular script, sorry for wording things wrong for you.
a client script is a loacl script.

Can you tell me where I put each script?

Sorry for the long wait.

You need to put the script inside of ServerScriptStorage, and then you are able to put the local script anywhere execpt for serverscriptstorage. However, if I were you I would put it inside of StarterPlayerScripts>CharacterScripts. Forgot the name entirely, but I know you’ll be able to find it.

local leaderstats = Instance.new(“leaderstats”);
This line needs to be "Folder in the parantheses.

Yeah, I’m sorry about that. I get things straight up wrong sometimes. But yes, people make mistakes nevertheless. Other than that, may I ask after you fix it that everything is working correctly?

How about trying to put the touch script in a local script and use a remote function
Also put the local script in StarterPlayer StarterPlayerScripts
Also put the remote function in ReplicatedStorage

Like this:
local db = false
local part = game.Workspace. ← Whatever your part name is

part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
if not db then
db = true
game.ReplicatedStorage.RemoteFunction:InvokeServer()
wait(3600)
db = false
end
end
end)

Then get a script in ServerScriptService and put this script down:

game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player)
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 100
end

And this should work

Tell me what event I need to use for this.
Also, help me understand this:
Where does each go?
Leaderboard Script -
Cash for Touch Script -

Leaderboard script goes in ServerScriptService and Cash for Touch Script goes in StarterPlayerScripts
in StarterPlayer

Also use a Remote Function and put it in ReplicatedStorage

Still doesn’t work, not working for some reason.