Hello guys, recently I’ve been working on a button system where i use region3’s to Define if the player is on the button. The point is to give/change the stats of the players inside the region3.
-
What do you want to achieve? Change the stats of all players in a same region!
-
What is the issue? If 2 players are standing in a region (button) it would only change the stats to one of the ‘x’ players
-
What solutions have you tried so far? I’ve tried alot of things and i know the issue is that i never told the script to change everyone’s stat in a region. I don’t know how to do that
while true do
wait()
local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
for i, part in pairs(partsInRegion) do
if part.Parent:FindFirstChild("Humanoid") ~= nil then
local char = part.Parent
local player = game.Players:GetPlayerFromCharacter(char)
while true do
if (RegionPart.Position - char:WaitForChild("HumanoidRootPart").Position).Magnitude >= 4 then
break -- This is just for people that leave the button's area it will stop the loop
end
wait(0.1)
if player.Leaderstats.Coins.Value >= amount then -- Stat changes
player.Leaderstats.Coins.Value -= amount
player.Leaderstats.Rebirths.Value += rebirths
player.Leaderstats.Tickets.Value += tickets
end
end
end
end
end
The script above is shortened to the only main part
Summary: The script above only changes the stats on 1 of ‘x’ players standing on the button and i don’t know how to fix it.
Thanks for any help in advance!