Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help this is suppoppsed to make my player switch lanes but wont work, help? :(

Asked by 7 years ago
01        --@LeafDoode & SilverBunny_Gd
02 
03_G.TheLane = script.Lane.Value
04 
05local Character = script.Parent
06local CityPath = game.Workspace.CityPath
07lanes = {game.Workspace.CityPath.Lane1,game.Workspace.CityPath.Lane2,game.Workspace.CityPath.Lane3}
08repeat wait() until Character.Humanoid
09 
10local UIS = game:GetService("UserInputService")
11_G.TheLane = 0
12UIS.InputBegan:connect(function(i)
13    if i.KeyCode == Enum.KeyCode.D then
14        _G.TheLane = _G.TheLane + 1
15        _G.Lane1 = lanes[_G.TheLane]
View all 44 lines...

1 answer

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

I don't think Global variables are necessary, just use a NumberValue in your player named Lanes to keep track.

01local rs = game:GetService("RunService")
02local UIS = game:GetService("UserInputService")
03local Character = script.Parent
04local player = game.Players:GetPlayerFromCharacter(Character)
05-- Just put a number value in player named Lane
06local lane = player:WaitForChild("Lane") --Instance.new("NumberValue", player)
07local humanoid = Character:WaitForChild("Humanoid")
08local CityPath = workspace:WaitForChild("CityPath")
09local lanes = {
10    CityPath:WaitForChild('Lane1'),
11    CityPath:WaitForChild('Lane2'),
12    CityPath:WaitForChild('Lane3')}
13 
14 
15local max_lanes = #lanes
View all 32 lines...
Ad

Answer this question