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

How to get how many of an object is in the workspace?

Asked by 6 years ago

I modified and scripted a teleport script, but im trying to make it so if there is more than one of the map in the Workspace it will not clone... Here is the script :

local db = 1

script.Parent.Touched:connect(function(z)

local h = z.Parent:FindFirstChild("Humanoid")
if h ~= nil and db == 1 then
local player = game.Players:GetPlayerFromCharacter(z.Parent)
if player~=nil then
local Lvl = player.leaderstats:FindFirstChild("Lvl") -- Name of Stat
if Lvl.Value >= script.Parent.Parent.LevelValue.Value then -- Change Lvl Value here
db = 0
 local map = game.ReplicatedStorage.Dungeon
map:Clone().Parent = game.Workspace
player.PlayerGui.TELEPORT.Frame.TextLabel.Text = "Entering Dungeon.. Good Luck!"
player.PlayerGui.TELEPORT.Script.Disabled = false
--Make Sure "TELEPORT" GUI is in StarterGUI
wait(2)
player.PlayerGui.TELEPORT.Script.Disabled = true
local p = game.Players:GetPlayerFromCharacter(z.Parent)
z.Parent.UpperTorso.CFrame = CFrame.new(39.9, 0.5, -130.2) --<--<--Put the position here
wait(2)
db = 1
end
end
end
end)

Thanks :D

1 answer

Log in to vote
0
Answered by 6 years ago

Try this

local map = game.ReplicatedStorage.Dungeon:Clone()
map.Parent = workspace
0
That works but i want it so, lets say another person walks on it, It would clone another. I want it so if there is already one in Workspace that it wont clone. MadNinja1004 0 — 6y
Ad

Answer this question