I’m working on a script that makes the players get teleported to a minigame that the script sends them to. I want to make it so that when the person which touches the model wins the game intermission restarts instead of the player’s name get stuck on there. This is my current script:
local s= script.Stat --the s meaning Stat
local vals = game.ReplicatedStorage.vals
t=0
while true do
t = 15
repeat
t = t-1
s.Value = "Intermission.. "..t
wait(1)
until t == 0
s.Value = "Game Starting!"
wait(2)
local mapselect = game.ReplicatedStorage.Games:GetChildren()
local choose = math.random(1,#mapselect)
curnum = 0
for i =1, #mapselect do
curnum = curnum +1
if curnum == choose then
mapselect[i]:Clone().Parent = workspace
curmap = mapselect[i].Name
s.Value = "We'll be playing "..mapselect [i].Name
end
end
wait(3)
local plrs = game.Players:GetChildren()
for i = 1, #plrs do
local num = math.random(1,15)
plrs[1].Character.Head.CFrame= CFrame.new (workspace.Teleports["Part"..num].Position)
plrs[i].Character.Parent = workspace.Ingame
end
t=100
repeat
t = t-1
s.Value = t.." seconds left"
wait(1)
until t==0 or vals.Winner.Value ~= ""
if vals.Winner.Value ~= "" then
s.Value = vals.Winner.Value.. " has won!"
vals.Winner.Value = ""
else
s.Value = "No one has won!"
end
wait(3)
local ingame = workspace.Ingame:GetChildren()
for i =1,#ingame do
local plr = game.Players:GetPlayerFromCharacter(ingame[i])
plr:LoadCharacter()
workspace[curmap]:Destory()
end
end
The error that I get in studio is Destroy is not a valid member of model.
robloxapp-20200409-1133282.wmv
I don’t know how to fix this. So please tell me what I did wrong and how I can fix it.
Thanks!