You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I am creating A pier that teleport players to the game in A different place.
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.
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.
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.