local debounce = false
local touchingplayers = {}
local touching = {}
local topCorner = script.Parent.TopCorner.Position
local bottomCorner = script.Parent.BottomCorner.Position
local region = Region3.new(bottomCorner, topCorner)
local runservice = game:GetService("RunService")
local players = game:GetService("Players")
local mood
runservice.Stepped:Connect(function(fps)
touching = workspace:FindPartsInRegion3(region)
for i, v in pairs(touching) do
if players:FindFirstChild(v.Parent.Name) then
touchingplayers[players[v.Parent.Name]] = true
end
end
touchingplayers = {}
end)
local function DrawRegion3(bottom, top)
local part = Instance.new("Part", script.Parent)
part.Name = "Region3Part"
part.Anchored = true
part.CanCollide = false
part.Transparency = 0.5
part.CFrame = CFrame.new((bottom+top)/2)
local size = top-bottom
part.Size = Vector3.new(math.abs(size.X), math.abs(size.Y), math.abs(size.Z))
return part
end DrawRegion3(bottomCorner, topCorner)
while true do
wait(0.4)
for player, inzone in pairs(touchingplayers) do
mood = game.ReplicatedStorage[player.Name.."'s Mood"]
mood.Entertainment.Value = math.clamp(mood.Entertainment.Value + 1, 0, 100)
end
end
COMMUNITY QUESTION
why the value is not increasing when player enters Region3?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.
