Hi all,
I want to make it so when a player enters a Region3, a gui will popup strictly for
that player and they can interact with it and such. I have it setup so that the
server script detects whenever a player enters the Region3. However, whenever the
server fires a remote event to the player, the client doesn’t receive it. I think it may have to
do with the variable “plyr,” but I’m unsure why.
Server script:
local repStorage = game:GetService("ReplicatedStorage")
local events = repStorage.Events
while true do
wait(.5)
for _, property in pairs(game.Workspace.Properties:GetChildren()) do
local boundBox = property:FindFirstChild("boundary_box")
local regionPart= boundBox
local pos1 = regionPart.Position - (regionPart.Size / 2)
local pos2 = regionPart.Position + (regionPart.Size / 2)
local region = Region3.new(pos1, pos2)
local partsInRegion = game.Workspace:FindPartsInRegion3(region, boundBox, 1000)
--// Contesting Script
local t = {}
for _, part in pairs(partsInRegion) do
local plyr = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)
if plyr and not table.find(t, plyr) then
table.insert(t, plyr)
events.showGui:FireClient(plyr)
if #t >= 2 then
print(property.Name.." is contested!")
end
end
end
end
end
Local Script:
local repStorage = game:GetService("ReplicatedStorage")
local userInput = game:GetService("UserInputService")
local localPlyr = game:GetService("Players").LocalPlayer
local events = repStorage.Events
--// Gui Handler
local function testF()
print("Receieved")
end
events.showGui.OnClientEvent:Connect(testF)
Any and all help is greatly appreciated