Hello there,
i am making some sort of case battle system used by rblxwild (no gambling, ingame points)
The script explains everything so here you go. Thats the local script whenever you select a case and start the game (for example blue case.)
game.Players.PlayerAdded:Connect(function(Client) -- setting variable for client
script.Parent.MouseButton1Click:Connect(function()
local propertiesData = { -- dont mind this
["Amount of Rounds"] = 3,
["Client"] = Client.Name
}
game.ReplicatedStorage.caseBattles.createCaseBattleBlue:FireServer(propertiesData, Client) -- creating properties and setting the parameter "client" as defined at line 1
end)
end)
This is the server script which handles the remote event:
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 = Server.PlayerGui.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.ImageLabel.Image = "rbxassetid://10910715327" -- Changing imagelabel to the hosts case selection.
template.ImageLabel.TextLabel = "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
while wait() do -- waiting till a player joined and we get a response
wait(.01)
caseBattlesFolder.otherPLR.joinCaseBattle.OnServerEvent:Connect(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
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
-- nothing because we havent got a response yet
end
end)
end
end)
It doenst print anything in the console, could someone help? Thanks!
Goodbye!