I want to make a race game but how?
Asked by
4 years ago Edited 4 years ago
I used the basic map (racing) from Roblox Studios and I'm done, but my friends tell me that some GUIs are not displayed. Could someone please explain the script to me? What I also try is a leaderboard that shows how many wins and money. If you win in the game now, the win value should increase by 1. so before I won, I still had 0 wins and 0 money but if I win it should then show 1 wins and 50 money
hier ist das skript was ich meine:
01 | local RaceManager = require( 391925754 ) |
02 | RaceManager:SetDebugEnabled( false ) |
03 | RaceManager:SetIntermissionDuration( 50 ) |
05 | local function pushNotificationForPlayer(player, message, duration) |
06 | local notificationFrameContainer = player.PlayerGui.RaceNotificationScreen:FindFirstChild( "NotificationFrameContainer" ) |
07 | local notificationFrame = Instance.new( "TextLabel" , notificationFrameContainer) |
08 | notificationFrame.Size = UDim 2. new( 1 , 0 , 1 , 0 ) |
09 | notificationFrame.Position = UDim 2. new( 0 , 0 , - 1 , 0 ) |
10 | notificationFrame.Text = message |
11 | for i, frame in ipairs (notificationFrameContainer:GetChildren()) do |
12 | frame.Position = frame.Position + UDim 2. new( 0 , 0 , 1 , 0 ) |
14 | delay(duration, function () |
16 | notificationFrame.BackgroundTransparency = i / 30 |
17 | notificationFrame.TextTransparency = i / 30 |
20 | notificationFrame:Destroy() |
24 | local function pushNotification(message, duration) |
25 | for _, player in ipairs (game.Players:GetPlayers()) do |
26 | pushNotificationForPlayer(player, message, duration) |
30 | local function onPlayerAdded(player) |
31 | local playerGui = player:WaitForChild( "PlayerGui" ) |
32 | local raceNotificationScreen = Instance.new( "ScreenGui" , playerGui) |
33 | raceNotificationScreen.Name = "RaceNotificationScreen" |
34 | local notificationFrameContainer = Instance.new( "Frame" , raceNotificationScreen) |
35 | notificationFrameContainer.Name = "NotificationFrameContainer" |
36 | notificationFrameContainer.BackgroundTransparency = 1 |
37 | notificationFrameContainer.BorderSizePixel = 0 |
38 | notificationFrameContainer.Size = UDim 2. new( 0.3 , 0 , 0.1 , 0 ) |
39 | notificationFrameContainer.Position = UDim 2. new( 0.35 , 0 , 0 , 0 ) |
42 | RaceManager.RaceStarted:connect( function () |
43 | pushNotification( "Race started!" , 3 ) |
46 | RaceManager.RaceFinished:connect( function (player) |
47 | local message = "Race over. " |
49 | message = message .. player.Name .. " won!" |
51 | message = message .. " Ran out of time." |
53 | pushNotification(message, 5 ) |
55 | for _, player in ipairs (game.Players:GetPlayers()) do |
56 | player:LoadCharacter() |
57 | if game.StarterGui.ResetPlayerGuiOnSpawn then |
63 | RaceManager.IntermissionStarted:connect( function () |
64 | local intermissionDuration = RaceManager:GetIntermissionDuration() |
65 | wait(intermissionDuration / 2 ) |
66 | pushNotification( "Race starting soon!" , intermissionDuration / 50 ) |
69 | RaceManager.LapFinished:connect( function (player, lap, duration) |
70 | local shortDuration = math.floor( tonumber (duration) * 1000 ) / 1000 |
71 | pushNotification(player.Name .. " finished lap " .. lap .. "/" .. RaceManager:GetNumLaps() .. " in " .. shortDuration .. " seconds" , 2 ) |
74 | for _, player in ipairs (game.Players:GetChildren()) do |
77 | game.Players.PlayerAdded:connect(onPlayerAdded) |