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
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! ^
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.
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)