so do i need to test with multiple players
No, just press play and the button will appear.
oh you want me to play test with the current server
I have no idea what your talking about now. just press play and look for the button that simple.
i did,…,.,.,.,…,.,.,…,.,.,.,.,.,…,.,.,.,.,.,.,.,.,.,.,.,.,
Hey, I made this to help you, the scripts have tips.
You can open this just dragging the file into the studio. Ask me smth if necessary.
download the place here:
match_system.rbxl (60.1 KB)
scripts used:
Server Script
-- services
players = game:GetService("Players")
teams = game:GetService("Teams")
replicatedStorage = game:GetService("ReplicatedStorage")
-- teams (you will locate the teams which you want to use)
local A = teams:WaitForChild("A")
local B = teams:WaitForChild("B")
-- important values
local match_lenght = 30 -- here you will set the lenght of the match
-- searching for the event \/
messageEvent = replicatedStorage:WaitForChild("events"):WaitForChild("messageEvent")
-- team values
-- it will be used to devide which team is the winner
local teamA = 0
local teamB = 0
-- functions
local function createStat(player, value) -- this will be called to create the player stat when he join the game
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local your_stat = Instance.new("IntValue", leaderstats) -- TODO >> remember that you need to change the stat variable name throughout the script
your_stat.Name = "stat_name" -- you can change the stat name like you want
end
local function decideWinner() -- it will be called to decide who is the winner
for _, player in players:GetPlayers() do -- list searching for all players on the game
local leaderstats = player:WaitForChild("leaderstats") -- searching for the leaderstats into the player
if player.Team == A then
teamA += leaderstats.stat_name.Value
elseif player.Team == B then
teamB += leaderstats.stat_name.Value
end
end
if teamA > teamB then
messageEvent:FireAllClients("Team A won!")
elseif teamB > teamA then
messageEvent:FireAllClients("Team B won!")
elseif teamB == teamA then
messageEvent:FireAllClients("It's a tie!")
end
end
-- calls
players.PlayerAdded:Connect(createStat)
-- the match loop
while task.wait(5) do
for i = match_lenght, 0, -1 do -- it will create a cooldown using the match_lenght seen before
messageEvent:FireAllClients(tostring("Time left: "..i)) -- it will display the cooldown to all players
wait(1)
end
decideWinner()
end
--[[ >> tips
to display a message, just use the command: messageEvent:FireAllClients("your message")
]]
Client Script
replicatedStorage = game:GetService("ReplicatedStorage")
messageEvent = replicatedStorage:WaitForChild("events"):WaitForChild("messageEvent")
messageEvent.OnClientEvent:Connect(function(msg) -- when the client receive the message sent from the server then
script.Parent.Text = msg -- the text will be the msg sent
end)
can you copyy and paste me the server script service code because my copy doesnt have it
yo why does it delete all my other leaderstats
I think theres an actually problem with my game, i used his method and it still didnt add the stats and just says its a tie every time
It’s happening bc you need to add smth that can add points into your player’s leaderstats.
In the message above I only created the leaderstats and made the winner either.
it still says tie hvgbnygrv6tgunbtvrftgjkhyfdrtfyuhgdtryuhgfdxsrtyu
You can manipulate the stats by the console(/console
in the chat or F9) and change your value, but only for tests.
ive been changing the value of my ls
works…,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,…,.,.,…,.,.,.,.,.,.,.,.,.,.,.,.,.,.,
hey how can i make the timer like minutes:Seconds instead of just seconds
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.