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
4 years ago

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

The script in workspace:

01local thicc = 31
02local function Damn() wait(30) end
03Damn(thicc)
04if game.Workspace.Time.Value == 0 then
05    target = CFrame.new(80.04, 0.5, -63.9) --could be near a brick or in a new area
06for i, player in ipairs(game.Players:GetChildren()) do
07 
08   if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
09 
10                player.Character.HumanoidRootPart.CFrame = target
11   end
12end
13    end

3 answers

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago
1wait(31)
2    target = CFrame.new(80.04, 0.5, -63.9) --could be near a brick or in a new area
3    for i, player in ipairs(game.Players:GetChildren()) do
4        if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
5            player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
6        end
7    end
Ad
Log in to vote
0
Answered by
uhi_o 417 Moderation Voter
4 years ago
Edited 4 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

01local function Damn()
02    wait(30)
03end
04Damn()
05local ObjectValue = game.Workspace.Time
06 
07ObjectValue.Changed:Connect(
08    function() --Parameter of property is not needed
09        if ObjectValueValue == 0 then
10            target = CFrame.new(80.04, 0.5, -63.9)
11            for i, player in ipairs(game.Players:GetPlayers()) do
12                if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
13                    player.Character.HumanoidRootPart.CFrame = target
14                end
15            end
16        end
17    end
18)

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 4 years ago
Edited 4 years ago

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

01local Players = game:GetService("Players") -- Add Players to a local function
02local thicc = 31 -- This has no use but useful for the OP?
03wait(30) -- No use for the "Damn" function
04local target
05if workspace.Time.Value == 0 then -- use workspace rather than game.Workspace
06    target = CFrame.new(80.04, 0.5, -63.9)
07    for _, plr in pairs(Players:GetPlayers()) do
08        if plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") then
09            plr.Character:SetPrimaryPartCFrame(target)
10        end
11    end
12end
0
Its a intvalue OFF_S4LE 127 — 4y
0
And it was working when i did while wait(1) do but it just teleported me OFF_S4LE 127 — 4y
0
but didnt stop teleporting OFF_S4LE 127 — 4y
0
nvm FunctionalMetatable 490 — 4y

Answer this question