hello there, i made an case battle system, please see the last post if u dont get me.
The problem is, that the player info is not getting replicated into the gui.
heres the script.
local rep = game:WaitForChild("ReplicatedStorage")
local caseBattlesFolder = game:WaitForChild("ReplicatedStorage"):WaitForChild("caseBattles")
caseBattlesFolder.createCaseBattleBlue.OnServerEvent:Connect(function(Server, Dictionary, Client) -- Defining "Client" as the local player who created the game. Dont mind dictionary. Therefore defining "Server" as all players in the game
local returned = false
local template = game.StarterGui.UI.Dashboard.TextLabel.CaseBattles.ScrollingFrame.Template:Clone() -- Telling the server that a new game has been created and creating a new frame to inform people
template.Visible = true
template.Parent = Server.PlayerGui.UI.Dashboard.TextLabel.CaseBattles.ScrollingFrame
template.ImageLabel.Image = "rbxassetid://10910715327" -- Changing imagelabel to the hosts case selection.
template.ImageLabel.TextLabel.Text = "Host: "..Client.Name -- Setting Text as the Host from CLIENT.Name
wait(0.01)
local newVal = Instance.new("StringValue") -- Creating a new value to check which button the player has clicked, it could be that another player created the game and player clicked other button and it would show up at both guis as client and the other one. Well we dont want this so were defining this.
newVal.Name = "USERDATA" -- Naming the value
newVal.Value = Client.Name -- Setting as the Name of client
newVal.Parent = template.ImageLabel.TextButton -- Parenting it into all player guis
local reservedForClient = game.ServerStorage.CaseBattle:Clone() -- main case battle gui, reserving for client
reservedForClient.Parent = Client.PlayerGui
local reservedForPlayer = game.ServerStorage.CaseBattle:Clone() -- main case battle gui, reserving for expected player
caseBattlesFolder.otherPLR.joinCaseBattle.OnServerEvent:Wait(function(Server, Val, expectedPLR)
if Val.Value == newVal.Value then -- checking if the player has clicked our game by the value seen at the upper line
print("returned = true") -- printing
returned = true -- changing returned to true, so we get the response
print(expectedPLR)
reservedForPlayer.Parent = expectedPLR.PlayerGui -- setting the gui reserved for expected player to expected player
local image = game.Players:GetUserThumbnailAsync(expectedPLR.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420) -- changing image to thumbnail of expected player
reservedForClient.Main.Content.secPLR.Image = image -- setting it as the expected plr profile picture
reservedForClient.Main.Content.callBot.Visible = false -- disabling the call bot button
reservedForPlayer.Main.Content.secPLR.Image = image -- the same just for the client
reservedForPlayer.Main.Content.callBot.Visible = false -- the same just for the client
wait(2) -- delay
warn("Case battle starting") -- Response sucessful and the battle starts now.
else
print("Test123") -- printing this as a test.
end
end)
end)
and this for the local script when u click join.
local expected = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if script.Parent:FindFirstChild("USERDATA") then
script.Parent.Text = "Connecting.."
game.ReplicatedStorage.caseBattles.otherPLR.joinCaseBattle:FireServer(script.Parent:FindFirstChild("USERDATA").Value, expected)
else
error("// ZFLIP CLIENT ERROR -- ERROR 404 NOT FOUND //") -- just errors because it didnt find a value
end
end)
When i click it it keeps saying connecting and it doenst print out anything.
Basically, i just want to create a variable for the player and i wanna replicate it through this gui:
When clicked, it will notify that the player joined, now its gonna create a variable for the player and it will also show the info on these placeHolders!
Could anyone help? Thanks!