local ting = 0 --debouncer
function onTouched(hit)
if ting == 0 then --debounce check
ting = 1 --activate debounce
check = game.Workspace.Cake.Parent("Player Who Owns the Part").Value
player = game.Parent.Parent:FindFirstChild("Humanoid")
cakeowner = hit.check
if cakeowner ~= nil then --If a cake is found, then
if player == check then
local stats = user:findFirstChild("leaderstats") --Find moneyholder
if stats ~= nil then --If moneyholder exists then
local cash = stats:findFirstChild("Cash") --Get money
function touched(hit)
if hit.Name == "Batter" then
Cash.Value = Cash.Value + 5
elseif hit.Name == "Shaped Batter" then
Cash.Value = Cash.Value + 10
elseif hit.Name == "Sugared Batter" then
Cash.Value = Cash.Value + 20
elseif hit.Name == "Unflavoured Cake" then
Cash.Value = Cash.Value + 25
elseif hit.Name == "Heated Cake" then
Cash.Value = Cash.Value + 50
elseif hit.Name == "Cake" then
Cash.Value = Cash.Value + 100
wait(5) --wait-time before button works again
end
end
ting = 0 --remove debounce
end
end
end
end
script.Parent.Touched:connect(onTouched)
I'm trying to make a script that gives you Cash when a part named Batter (or the others) touches the part that contains the script.
I need the script to read the Batters ObjectValue string, which has a players name in it.
If the players name equals the ObjectValue, then it should give that person Cash.

1 comment
replied to your comment