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

Teleport when stats changed?

I want to do the next thing. When you have "Objects" (Stat) in value = 5 ,you need to be teleported, i use the next script,but it doesnt works. Whats the problem?

Position=Vector3.new(-46.078, 5.046, -1105.82)

objects.Changed:Connect(function()
	 
	    if objects.Value == 5 then 
	
	     
	 local objects = Instance.new("IntValue", stats)
	FindFirstChild("Humanoid") then
	Torso.CFrame=CFrame.new(Position)
	    end
	 
	end)

1 answer

local pos = Vector3.new(-46.078, 5.046, -1105.82)
local stats = game.Players.LocalPlayer.leaderstats -- define as stats
local objects = Instance.new("IntValue", stats)
local char = game.Players.LocalPlayer.Character
local tor = char:WaitForChild("Torso") -- r15 "UpperTorso"

objects.Changed:Connect(function()
if objects.Value == 5 then
    tor.CFrame=CFrame.new(pos)
else print("Objects value isn't 5")
end
end)

You didn't define stats and you defined objects later on in the change functions so it returned the function as nil.

And you didn't define the torso...

Next time please give full code..

2 comments

0

Thanks!,I will test it later ^^

0

The parent argument to Instance.new is deprecated and slows down game performance.

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