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

Teleport Only If IntValue Is?

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.

1 comment

0

What's your problem and what part it didn't expect to work?

2 answers

✓ Accepted answer

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.

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.

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