Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
OFF_S4LE 127
3 years ago

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

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago
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

Ad
Log in to vote
0
Answered by
uhi_o 417 Moderation Voter
3 years ago
Edited 3 years ago

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.

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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
0
Its a intvalue OFF_S4LE 127 — 3y
0
And it was working when i did while wait(1) do but it just teleported me OFF_S4LE 127 — 3y
0
but didnt stop teleporting OFF_S4LE 127 — 3y
0
nvm FunctionalMetatable 490 — 3y

Answer this question