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

Why doesnt my teleport script teleport me ? (plz help)

No errors, just doesnt teleport me though everything else works fine :)

The script in workspace:

local thicc = 31
local function Damn() wait(30) end
Damn(thicc)
if game.Workspace.Time.Value == 0 then
	target = CFrame.new(80.04, 0.5, -63.9) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
  
   if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
				      
				player.Character.HumanoidRootPart.CFrame = target
   end
end
	end
	

3 answers

wait(31)
    target = CFrame.new(80.04, 0.5, -63.9) --could be near a brick or in a new area
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
            player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
        end
    end

Maybe this, used Players:GetPlayers() instead, but does Workspace.Time exist and is it a NumberValue?

local Players = game:GetService("Players") -- Add Players to a local function
local thicc = 31 -- This has no use but useful for the OP?
wait(30) -- No use for the "Damn" function
local target
if workspace.Time.Value == 0 then -- use workspace rather than game.Workspace
	target = CFrame.new(80.04, 0.5, -63.9)
	for _, plr in pairs(Players:GetPlayers()) do
		if plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") then
			plr.Character:SetPrimaryPartCFrame(target)
		end
	end
end

4 comments

0

Its a intvalue

0

And it was working when i did while wait(1) do but it just teleported me

0

but didnt stop teleporting

0

nvm

So your if statement is only running once which means the Value can change at any time and do nothing. So for that reason we are going to use .Changed

local function Damn()
    wait(30)
end
Damn()
local ObjectValue = game.Workspace.Time

ObjectValue.Changed:Connect(
    function() --Parameter of property is not needed
        if ObjectValueValue == 0 then
            target = CFrame.new(80.04, 0.5, -63.9)
            for i, player in ipairs(game.Players:GetPlayers()) do
                if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
                    player.Character.HumanoidRootPart.CFrame = target
                end
            end
        end
    end
)

Basically, we wait 30 seconds then connect the .Changed event for every time the value changes it will fire the Signal.

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