Hello! I am having an issue passing down a list filled with proximity prompts from the server to the client. These scripts interact with each other so that when a player is downed a folder is created with the name of the players who are down and within these folders have the proximity prompts that are cloned from replicated storage but I want to have them be sent to the players so that they will get a list of all the proximity prompts of the downed players so that the local script can hide specific prompts for each client. Survivors can only see the revive prompt and the downed player cannot see their own(or others will be implemented later, don’t worry about it).
Survivor Local Script:
local replicatedStorage = game.ReplicatedStorage
local survivorDownEvent = replicatedStorage.GlobalEvents.survivorDown
local survivorRevived = replicatedStorage.GlobalEvents.survivorRevived
local player = game.Players.LocalPlayer
local updatePlayerPosition = replicatedStorage.GlobalEvents.updatePlayerPos
local character = player.Character
local rootPart = character:WaitForChild("HumanoidRootPart")
local humanoid = character:FindFirstChild("Humanoid")
local animate = character:WaitForChild("Animate")
local maxHealth = humanoid.Health
humanoid.HealthChanged:Connect(function()
local health = humanoid.Health
if health == 1 then
survivorDownEvent:FireServer()
humanoid.WalkSpeed = 3
end
end)
survivorDownEvent.OnClientEvent:Connect(function(folder, playerlist, reviveList, GhostList)
print("client side!")
print(playerlist,reviveList,GhostList)
for i, v in pairs(playerlist) do--forloop going through the playerlist one by one.
print("v:", v, "playername:",player.Name)
if v == player.Name then--if prompts belongs to player,
print(reviveList[i])
print(reviveList[i].Parent.Parent)
reviveList[i].Enabled = false--hide their prompts from themself
GhostList[i].Enabled = false
else if v ~= player.Name then --if name from playerlist does not equal player's name
GhostList[i].Enabled = false --hide the ghost pickUp prompts from the player
playerlist[i].Enabled = true
end
end
end
end)
ServerSide Script:
local handler = require(script.Handler)
local replicatedStorage = game.ReplicatedStorage
local survivorDownEvent = replicatedStorage.GlobalEvents.survivorDown
local survivorRevivedEvent = replicatedStorage.GlobalEvents.survivorRevived
local proxes = game.ReplicatedStorage.GlobalEvents.playerDownRevives
survivorDownEvent.OnServerEvent:Connect(function(player)
local survivorDownFolder = game.Workspace:WaitForChild("survivorDownFolder", 0.1)
if survivorDownFolder then
print("Folder already exists")
createPlayerFolder(player, survivorDownFolder)
end
if not survivorDownFolder then
local survivorDownFolder = Instance.new("Folder", workspace)
--print("created folder")
survivorDownFolder.Name = "survivorDownFolder"
createPlayerFolder(player, survivorDownFolder)
end
end)
function createPlayerFolder(player, folder)
local playerFolder = folder:WaitForChild(player.Name, 0.1)
if playerFolder then
print("Player subfolder is already made")
end
if not playerFolder then
--checkIfGame is Over()
--else
--print("created player subfolder")
playerFolder = Instance.new("Folder", folder)
playerFolder.Name = player.Name
local revivePrompt = proxes.reviveBlock:Clone()
local pickUpPrompt = proxes.pickUpBlock:Clone()
revivePrompt.CFrame = player.Character.HumanoidRootPart.CFrame
pickUpPrompt.CFrame = player.Character.HumanoidRootPart.CFrame
revivePrompt.Parent = playerFolder
pickUpPrompt.Parent = playerFolder
local weld = Instance.new("Weld")
local weld2 = Instance.new("Weld")
weld.Part0 = revivePrompt
weld2.Part0 = pickUpPrompt
weld.Part1 = player.Character.HumanoidRootPart
weld2.Part1 = player.Character.HumanoidRootPart
weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
weld2.C0 = weld2.Part0.CFrame:ToObjectSpace(weld2.Part1.CFrame)
weld.Parent = weld.Part0
weld2.Parent = weld2.Part0
table.insert(handler.currentDownPlayers, player.Name)
table.insert(handler.currentPlayerProximityPrompts, revivePrompt.reviveProx)
table.insert(handler.currentGhostProximityPrompts, pickUpPrompt.pickUpProx)
--print("Current DownedPlayers:",handler.currentDownPlayers)
print("Ghost and Revive list:", handler.currentGhostProximityPrompts, handler.currentPlayerProximityPrompts)
for i, v in pairs(game.Teams.Survivors:GetPlayers()) do
survivorDownEvent:FireClient(v, folder, handler.currentDownPlayers, handler.currentPlayerProximityPrompts, handler.currentGhostProximityPrompts)
end
end
end
Handler Script:
local Handler = {}
Handler.currentDownPlayers = {} --
Handler.currentPlayerProximityPrompts = {}
Handler.currentGhostProximityPrompts = {}
return Handler