How can I Transfer a value from one script to another in a simple way?
I am new to Lua coding, I have a fair understanding of python which I can see some similarities between the two and I would like some help to create a mechanic in my game.
I would like to transfer the value "mins" from this script which counts how many minutes the player has been in the game:
01 | function onPlayerEntered(newPlayer) |
03 | local stats = Instance.new( "IntValue" ) |
04 | stats.Name = "leaderstats" |
05 | local player = newPlayer |
06 | mins = Instance.new( "IntValue" ) |
08 | mins.Name = "Minutes Riding" |
14 | stats.Parent = newPlayer |
17 | mins.Value = mins.Value + 1 |
18 | if mins.Value > = 60 and mins.Value < 120 then |
19 | player.TeamColor = game.Teams [ "2nd Class" ] .TeamColor |
20 | else if mins.Value > = 120 and mins.Value < 180 then |
21 | player.TeamColor = game.Teams [ "1st Class" ] .TeamColor |
22 | else if mins.Value > = 180 and mins.Value < 240 then |
23 | player.TeamColor = game.Teams [ "Business Class" ] .TeamColor |
24 | else if mins.Value > = 300 then |
25 | player.TeamColor = game.Teams [ "Non-Stop Rider" ] .TeamColor |
37 | game.Players.ChildAdded:connect(onPlayerEntered) |
into this script so that I can enable players who have played a certain time to be able to use a teleport door to help them reach the next stage:
01 | tele = script.Parent.Parent.TeleSettings.Position.Value |
06 | function onTouched(hit) |
08 | player = game.Players:GetPlayerFromCharacter(hit.Parent) |
10 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
12 | if (This is where I would like the value to go) > = lvl then |
14 | hit.Parent.Torso.CFrame = CFrame.new(tele) |
20 | script.Parent.Touched:connect(onTouched) |
I'm not 100% on things such as remote events and the difference in script types, but I am happy to give all options a go if I can understand them!
Thanks a lot