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

Teleport player when stats are 5?

Asked by 6 years ago

I modified and asked whats wrong with that script four times this day,it still not working

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

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

You need to be teleported when your stats called "Objects" are = 1 ,but its not working

Where i need to place the script,its local or normal script?

My game has filtering disabled

All people in server needs to be teleported when a person gets "Objects" value = 5

0
You can always teleport a player to a specific block! AIphanium 124 — 6y
0
Do you get anything ftom the output? AswormeDorijan111 531 — 6y

3 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Well, if you want to make this teleport for all players when their stats called Objects are 5. I would put this in a Local Script and put it inside of the StarterGui. This script will teleport the player if his stats are 5. In my case, I would use :SetPrimaryPartCFrame() as you know, the player already has the default defined PrimaryPart so it will move it, it is easier. Here's your code:

-- Variables

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Stats = Player:WaitForChild("leaderstats")
local Objects = Instance.new("NumberValue")
Objects.Value = 0
Objects.Parent = Stats
Objects.Name = "Objects"

-- Code

Objects.Changed:Connect(function()
    if Objects.Value >= 5 then
        Character:SetPrimaryPartCFrame(CFrame.new(-46.078, 5.046, -1105.82))
    else
        print("Objects value isn't 5 or greater than 5.")
    end
end)

Hope it helped! ^

0
Still not working,can you add me on roblox to see the problem? SpringtraPlayer 16 — 6y
0
Updated my answer AswormeDorijan111 531 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Firstly, Filtering Enabled is now a FORCED part of all Roblox games now, whether or not you've ticked it on or off.

However, that does not mean to just give up!

This can be done via a script simply placed within the Workspace or SSS.

All people in server needs to be teleported when a person gets "Objects" value = 5

All people when one person? If so:

local cframe = CFrame.new(Vector3.new(-46.078, 5.046, -1105.82))
game.Workspace.Players.PlayerAdded:connect(function(plr) 
    local ldrst = Instance.new("Model")
    ldrst.Name = "leaderstats"
    local objects = Instance.new("IntValue")
    objects.Name = "Objects"
    objects.Parent = ldrst
    objects.Changed:connect(function(num)
        if num >= 5 then
            for i,v in pairs(game.Players:GetChildren()) do
                if v.Character:FindFirstChild("HumanoidRootPart") then
                    v.Character.HumanoidRootPart.CFrame = cframe + Vector3.new(math.random(-5,5), 0, math.random(-5,5)) --Attempts to spread the players
                end
            end
        end
    end)
end)

Perhaps you meant only the person who reached 5? if so.

local cframe = CFrame.new(Vector3.new(-46.078, 5.046, -1105.82))
game.Workspace.Players.PlayerAdded:connect(function(plr) 
    local ldrst = Instance.new("Model")
    ldrst.Name = "leaderstats"
    local objects = Instance.new("IntValue")
    objects.Name = "Objects"
    objects.Parent = ldrst
    objects.Changed:connect(function(num)
        if num >= 5 then
            if plr.Character:FindFirstChild("HumanoidRootPart") then
                plr.Character.HumanoidRootPart.CFrame = cframe
            end
        end
    end)
end)

No localscripts required! Just a normal script either in SSS or workspace. Excuse any typos or errors I may have made; they should be easy to fix if they turn up.

0
First one not working. SpringtraPlayer 16 — 6y
Log in to vote
-1
Answered by 6 years ago

You had the right idea, but the Parent Argument to Instance.new() is deprecated. This also needs to be a ServerScript in SSS or Workspace. Try this:

game.Players.PlayerAdded:Connect(function(player)
local pos = Vector3.new(-46.078, 5.046, -1105.82)
local stats = player.leaderstats
local Objects = Instance.new("IntValue")
Objects.Name = "Objects"
Objects.Parent = stats
local char = player.Character
local tor = char:WaitForChild("Torso")

objects.Changed:Connect(function()
if objects.Value == 1 then
tor.CFrame = CFrame.new(pos)
else
print("Objects Value isn't 5")
end)
0
lol, it don't have to be ServerScript in order to work. AswormeDorijan111 531 — 6y
0
And your script also dont work BTW. AswormeDorijan111 531 — 6y

Answer this question