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

Teleport when stats changed?

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
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..

0
Thanks!,I will test it later ^^ SpringtraPlayer 16 — 5y
0
The parent argument to Instance.new is deprecated and slows down game performance. User#19524 175 — 5y
Ad

Answer this question