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

Teleport Only If IntValue Is?

Asked by 3 years ago
script.Parent.Triggered:Connect(function(player)
local char = player.Character   
    if player.leaderstats:WaitForChild("Rebirths").Value >= script.Parent.Parent.Parent.Price.Value then
        script.Disabled = true
        script.Parent.Enabled = false
        player.PlayerGui.FX.TextLabel.Visible = true
        player.PlayerGui.FX.Circle:TweenSize(UDim2.new(0, 0,2.5, 0))
        wait(1)
        char.Head.CFrame = CFrame.new(game.Workspace:WaitForChild("50000").Position)
        wait(1)
        player.PlayerGui.FX.Circle:TweenSize(UDim2.new(1.5, 0,2.5, 0))
        script.Disabled = false
        script.Parent.Enabled = true
        player.PlayerGui.FX.TextLabel.Visible = false
    else
        player.PlayerGui.MainUI.Error.Visible = true
        wait(1)
        player.PlayerGui.MainUI.Error.Visible = false
    end
end)

This is my code for teleporting a player to a block (named 50000) if it touches a teleportion block (and it has only 0 rebirth) what I am trying to do is that it will only teleport if a intvalue is 1. How would I do that?

Thanks.

0
What's your problem and what part it didn't expect to work? Xapelize 2658 — 3y

2 answers

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

NOTE: Use this as a LocalScript.

Consider replacing every player.PlayerGui to game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")

Also, if the script self-disabled itself, it can't enable it back lol. (Except for another script controls and enable it back!)

Edit: Please change the :WaitForChild("50000") to .["50000"]. It causes an infinite yield error if waiting a brick that already existed in the workspace.

Ad
Log in to vote
0
Answered by 3 years ago

I dont know if this is the problem but you are disabling the script when you attempt to teleport, which will just destroy the thread and discontinue it...it would be better to disable the script after you have teleported

And if that does not work, try using char:MoveTo() rather than changing the CFrame of the head.

Answer this question