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)```
#how can i make bool value be true for one player while keeping my script working?
1 messages · Page 1 of 1 (latest)
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
So the boolvalue turns on despite the players not touching it?
Can you be more clear as to what the problem is exactly?
The bool value turns on normally
But i want it to turn on ONLY for the player that touches it
make
replicatedStorage:FindFirstChild("yellowcat").Value = true
in a local script
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
i would have to create a remote event for every single cat
and we're planning around 100 😭
no
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)
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
_ _
you can place a boolValue in every cat
in the workspace ofc
and modify that value through the localscript