I am trying to create a system where every round, a different player is picked to become the killer, and on a GUI it cycles through every player until it lands on the selected killer. How would I bring this to life and what is the best way to approach this?
Many thanks in advance.
- Get a list of all players in the game.
- Pick one player as the killer each round.
- Set up a GUI to display player names.
- Use a loop to cycle through player names visually until it lands on the killer.
- Stop cycling and highlight the selected killer.
You can tweak the timing and visuals to make it better! This is how I would do it.
How would I do step 4? Is there a way to make it slow down when landing on the killer?
local players = game.Players:GetPlayers()
local killerIndex = math.random(1, #players)
local gui = script.Parent:WaitForChild("YourGuiName")
local textLabel = gui:WaitForChild("TextLabel")
local speed = 0.1
local displayIndex = 1
while true do
textLabel.Text = players[displayIndex].Name
wait(speed)
displayIndex = (displayIndex % #players) + 1
if displayIndex == killerIndex then
speed = speed + 0.05
else
speed = math.max(speed - 0.01, 0.1)
end
end
It would look something like this.
Thank you so much! How would I change the script so it stops on the killer, not on the first time but after cycling through the players a few times, because currently it just continues forever.
Would I use something along the lines of if speed == 3 then…
local players = game.Players:GetPlayers()
local killerIndex = math.random(1, #players)
local gui = script.Parent:WaitForChild("YourGuiName")
local textLabel = gui:WaitForChild("TextLabel")
local speed = 0.1
local displayIndex = 1
while true do
textLabel.Text = players[displayIndex].Name
wait(speed)
displayIndex = (displayIndex % #players) + 1
if displayIndex == killerIndex then
speed = speed + 0.05
textLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
wait(1)
break
else
speed = math.max(speed - 0.01, 0.1)
end
end
```. All you would need to do is add a break in there alongside wait(1)
2 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.