I’m trying to make this script make it so the coins go up by one every time the tool the script is in hits a part called Stone.
script.Parent.Handle.Touched:Connect(function(hit, Coins)
if hit:FindFirstChild("Humanoid") == nil then
if hit ~= nil then
if hit.name == ("Stone") then
hit:Destroy()
local Coins = game.Players.Player("leaderstats").Coins.Value + 1
Coins
end
end
end
end)
script.Parent.Handle.Touched:Connect(function(hit, Coins)
if hit:FindFirstChild("Humanoid") == nil then
if hit ~= nil then
if hit.name == ("Stone") then
local character = script.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character)
hit:Destroy()
local Coins = player.leaderstats.Coins
Coins.Value += 1
end
end
end
end)
Getting character by doing script.Parent.Parent
then getting player by using game.Players:GetPlayerFromCharacter(character)
By the way, I don’t think “hit” can be nil, and your code is just too long. You just need to see if the name of the “hit” is “Stone” (since those simple named players don’t usually play games xd)