Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I add to this value correctly?

Asked by 6 years ago

I have this script that's not working I'm trying to make a fishing game where you fish to get money but I want it to show you how many fish you collected how do I add one to a string value?

script.Parent.Touched:connect(function(hit)
    local player = game.Players[hit.Parent.Name]
    player.FishCollected.Value = "0/32" +1
end)

1 answer

Log in to vote
1
Answered by 6 years ago
local players = game:GetService("Players")
local fishAmount = 0

script.Parent.Touched:Connect(function(part) -- Use Connect, connect is deprecated.
    fishAmount = fishAmount + 1
    local plr = players:GetPlayerFromCharacter(part.Parent)
    if plr then
        plr.FishCollected.Value = fishAmount.."/32"
    end
end)
Ad

Answer this question