#how can i make bool value be true for one player while keeping my script working?

1 messages · Page 1 of 1 (latest)

shut patio
#
local badge = game:GetService("BadgeService")
local part = script.Parent
local replicatedStorage = game.ReplicatedStorage
-- Table to keep track of players who have already triggered this part
local triggeredPlayers = {}

part.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
        local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
        if player and not triggeredPlayers[player.UserId] then
            triggeredPlayers[player.UserId] = true
            badge:AwardBadge(player.UserId, 2124855712)
            local yellowcat = replicatedStorage:FindFirstChild("yellowcat")
            if yellowcat then
                yellowcat.Value = true
            end
            print("code works")
            local leaderstats = player:FindFirstChild("leaderstats")
            if leaderstats then
                print("leaderstats found for", player.Name)
                local cats = leaderstats:FindFirstChild("Cats")
                if cats and cats:IsA("IntValue") then
                    print("cats value before:", cats.Value)
                    cats.Value = cats.Value + 1
                    print("cats value after:", cats.Value)
                else
                    print("cats IntValue not found in leaderstats")
                end
            else
                print("leaderstats not found for", player.Name)
            end
        end
    end
end)```
#

so this is my code for giving player badge and adding to the cats value, but i want to make bool value that will turn true for user when they touch the cat

#

rn the boolvalue turns on for everyt player

fair pilot
#

Can you be more clear as to what the problem is exactly?

shut patio
#

But i want it to turn on ONLY for the player that touches it

faint mortar
#

maybe you can add a remote event in replicated storage, with that line being replaced with:

replicatedStorage:FindFirstChild("RemoteEvent"):FireClient(player)
#

and have a localscript in starterplayerscripts listen for the event

shut patio
#

and we're planning around 100 😭

faint mortar
#

only one

#

you can add values in remote events

#

so you can let each cat have an id

#

that gets sent to the player

#
replicatedStorage:FindFirstChild("RemoteEvent"):FireClient(player, 001)
shut patio
#

every cat would have a different bool value, i was thinking about making a wikipedia with the cats, a picture of the cat and in a corner red/green circle, if the bool value = true the circle would be green for a specific cat

faint mortar
#

in the workspace ofc

#

and modify that value through the localscript