Hi, I got this script of YouTube for a touch event that gives player stored cash, but how I could I alter this script to give the same variables but without having to touch (such as when the player joins, or a module, or being called, etc...) Any help is appreciated.
local ting = 0 --debouncer
function onTouched(hit)
if ting == 0 then --debounce check
ting = 1 --activate debounce
check = hit.Parent:FindFirstChild("Humanoid") --Find the human that touched the button
if check ~= nil then --If a human is found, then
local user = game.Players:GetPlayerFromCharacter(hit.Parent) --get player from touching human
local stats = user:findFirstChild("leaderstats") --Find moneyholder
if stats ~= nil then --If moneyholder exists then
local cash = stats:findFirstChild("Money") --Get money
cash.Value = cash.Value +1000 --increase amount of money by the number displayed here (1000)
wait(100) --wait-time before button works again
end
end
ting = 0 --remove debounce
end
end
script.Parent.Touched:connect(onTouched)

2 comments
No I'm asking how after that the player is required to touch the part to get cash, how could I remove that part and just give the player cash without having to touch it, such as when the player joins?
Oh that might require DataStore to let the player join again and get cash