Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I'm in doubt if the script will teleport all players?

Hello, I'm creating a mini game where the player escapes from the lava. The minigame starts when a player presses a button, so to make all the players teleport and the lava starts to move I created a script, note:


 lava = game.Workspace.lava2
local teleporte = script.Parent


function onClicked()
   
local p = game.Players:GetChildren()
for i = 1, #p do
p[i].Character:MoveTo(Vector3.new(-55.831, 11.008, 183.894))
teleporte.ClickDetector.MaxActivationDistance = 0
local player = game.Players:GetPlayers()

	for i, p in pairs(player) do
		if game.Workspace:FindFirstChild(p.Name) then
			p.Character.HumanoidRootPart.Orientation = Vector3.new(0, -1.01, 0)
			
		end
	end
	

		
end
end
 
script.Parent.ClickDetector.MouseClick:connect(onClicked)

local lava = game.Workspace.lava2
local numero = 0
function clicar()
	while true do
	wait(0.8)
	lava.Size = lava.Size+Vector3.new(0,0,4)
	numero = numero + 1
	print(numero)
	if numero == 221 then
		lava.Size = Vector3.new(18, 40.2, 1)
		wait(0.00001)
		break
	end
	end
	end
	script.Parent.ClickDetector.MouseClick:Connect(clicar)
	

I think that in the script there is no problem, what I'm worried about is whether the script I made to teleport players and rotate them will teleport and rotate everyone and not just a player. Can someone help me with this?

I also think we could improve the script that makes the lava move, because the lava moves in two directions, when it should be just one

1 comment

1

If you're unsure if it works with multiple people then go into the test tab and start a server with atleast 2 players

1 answer

✓ Accepted answer

Everything looks great so far but you forgot one thing, the method :MoveTo() is not for the character but for the humanoid instead. Also it may be better to call the function instead of causing another event to happen.

Here’s your script that has the bug fixed:


 lava = game.Workspace.lava2
local teleporte = script.Parent


function onClicked()

local p = game.Players:GetChildren()
for i = 1, #p do
p[i].Character.Humanoid:MoveTo(Vector3.new(-55.831, 11.008, 183.894))
teleporte.ClickDetector.MaxActivationDistance = 0
local player = game.Players:GetPlayers()

    for i, p in pairs(player) do
        if game.Workspace:FindFirstChild(p.Name) then
            p.Character.HumanoidRootPart.Orientation = Vector3.new(0, -1.01, 0)

        end
    end



end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

local lava = game.Workspace.lava2
local numero = 0
function clicar()
    while true do
    wait(0.8)
    lava.Size = lava.Size+Vector3.new(0,0,4)
    numero = numero + 1
    print(numero)
    if numero == 221 then
        lava.Size = Vector3.new(18, 40.2, 1)
        wait(0.00001)
        break
    end
    end
    end
    script.Parent.ClickDetector.MouseClick:Connect(clicar)

3 comments

0

You can use MoveTo() on models aswell and if done it will teleport the model to the specified location, which the person seemed to want. Whilst using it on the humanoid makes the humanoid walk to the specified location

0

I didn’t know that until now lol

0

oh thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.