Where would I place the intValue in this script?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I am creating A pier that teleport players to the game in A different place.

  2. What is the issue? I must do code that when the intValue is greater than 6 for example the game teleport the players but I do not know where to put this in.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is the Script for teleporting players
local TeleportService = game:GetService("TeleportService")

local placeID_1 = 5077444848 --Lobby
local placeID_2 = 5077513028 --Game

local peoplePlaying = Instance.new("IntValue")-- The people on the pier
local isPlaying = Instance.new("BoolValue")-- If the game will teleport

local isPlaying = false --Will set to true 

function onPartTouch(Pier)
	local player = game.Players:GetPlayerFromCharacter(Pier.Parent)
if  local 	 peoplePlaying  =>6
if player then
		TeleportService:Teleport(placeID_1, player)
	end
end
script.Parent.Touched:Connect(onPartTouch) 

(The comments were not put their to explain the script they were just Already their. Just incase you felt patronized.
I need to know whether to but this before or after the function

if
   local peoplePlaying =< 6
then
function onPartTouch(Pier)

I am new to scripting and wrote this code entirely myself so if their are mistakes I would appreciate it if you told me. However, the main issue is the placement of the second code block.

2 Likes

Parent the IntValue in the player. Then, use the FindFirstChild Function and find taht intvalue. You may want to name the IntValue to something else or even use a string value instead.

1 Like

If I parent it to the player will it still teleport all the necessary players.

Yes, I actually have that in my current game I’m developing

1 Like

Why exacly you need to use a int and bool values? Lua variables can store any type of values, so you could do this instead:

local peoplePlaying = 0
local isPlaying = false

It’s more performant and easier to manage this way.

1 Like

Thanks! I am no where near as good as scripting as you seem to be but this has been really helpful.

1 Like

Why do int and bools exist then?

In order to teleport specific users, you’ll need to put some sort of tag inside them.

You mean the “tag” as the player? He could store the players inside a table, iterate it, then teleport every player to the game.

1 Like

Yeah, I can do both of these options! They both sound good!

I advice using my method because it’s more performant and doesn’t require creating any instances (which is usually preferred). In this case, there’s no problem on placing instances in the player because the server can’t see if a exploiter tries to change it. When you work with things such as shops, you should keep the money of each player on the server so they can’t modify it. If they attempt to buy something, check it on a serverscript to make sure that they can’t buy anything without enough cash.