As seen in this video, it doesn’t teleport the players to the arena, but instead it says that the game is over, and this goes on forever.
The code is from AlvinBlox’s swordfighting game series, part 3.
CODE: Code - Pastebin.com
As seen in this video, it doesn’t teleport the players to the arena, but instead it says that the game is over, and this goes on forever.
The code is from AlvinBlox’s swordfighting game series, part 3.
CODE: Code - Pastebin.com
for i, players in pairs(game.Players:GetPlayers()) do if player then table.insert(plrs,player)
end end
It may be helpful to specify the number position within your table using:
table.insert(plrs, numberposition, player)
Also, this is incorrect
if character then -- Teleport them
character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints.CFrame
table.remove(AvailableSpawnPoints,1) -- Give them a sword
The script attempts to set the players HumanoidRootPart CFrame to a variable called, “AvailableSpawnPoints,” however this variable is a table, which does not have a CFrame property.
The second argument to table.insert is the item that is being inserted.
That is not the only way it can work.
run this in studio and the output will be the third parameter.
local ourtable = {}
table.insert(ourtable,1,"String Value")
for i, v in pairs(ourtable) do
print(v)
end
the lua article you posted specifies this in the first paragraph.
Edit: I guess the method you gave is more efficient
Alright, I’ll try that solution.
Just a correction, I was wrong to say that your table.insert method was incorrect, since it is actually a perfectly valid method, and I have edited the original post. Although, I’m almost positive that the CFrame thing was your issue.
You need to specify which member of your table you want to use. To do this you can either search the entire table using something with pairs, or you could just specify which member of the table you want by its number position.
character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1] -- [1] will select the object that occupies the number position of 1 inside the table(the first member of the table).
One reason you might want to use this method besides being less lines of code is that you already know which number position you want to remove shortly after.
table.remove(AvailableSpawnPoints, 1) -- removing the same object we just inserted into the table
For some reason I cannot open that link, what was the output error?
ro-defender lol
I found a typo: [quote=“Jaguar515_YT, post:1, topic:235155”]
else if character:FindFirstChild(“GameTag”) then character.GameTag:Destory() end
[/quote]
Destory
Does it work now?
Still no…
8 posts were merged into an existing topic: Off-topic and bump posts
Please do not post along the lines of “contacted you on Discord” / “gave you Team Create access” on a help request – it’s not relevant for other readers. Use DMs for those purposes.
Hm, I think it’s best to rescript this. If you wish to rescript this you can gain me access to the game via team create. If you don’t want/don’t know how to, you can send me a copy of the game, let em edit it, then I’ll send you a fixed copy of the game. If you really do want this, you can simply dm me via devforum or roblox
character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[math.random(1, #AvailableSpawnPoints)].CFrame
Fixed line. It will teleport players to arena.
This should be
repeat wait(1) until #game:GetService('Players'):GetPlayers() >= 2
This code is wrong
AvailableSpawnPoints is a table of spawn points, consider looping through them or just selecting the first spawn point.
Overall, you need to properly put your code in either a link to a site such as pastebin which we can access which has the code or correctly format it like this:
```lua
– code
```
It would be good if you told us what the output was, and if you did any debugging prior.
This section is also not a place to talk one on one about a topic, any user should be able to look at the topic and all posts should contribute in somewhat to the solution of the problem. If you are talking about doing stuff in teamcreate please put that in your direct messages…
As for the table.insert
debate, there are two methods of inserting a item into a table:
Method1:
table.insert(Table, Value)
This inserts Value into the Table at the key #Table + 1
This method is useful for inserting an item and the nearest available key (basically looping through the whole table and if a key is available it will set it to that, looping from 0 to math.huge or some insane number)
Method2:
table.insert(Table, Key, Value)
This inserts Value into the Table at the key Key, but only will work if Key is a number.
Using this method is inefficient and is basically doing
Table[Key] = Value
The code you posted in correction to the unnecessary repeat loop is also wrong. You’re attempting to compare a number to a table value, which will throw an error. You forgot to attach # to the beginning, as GetPlayers returns a table.
#game:GetService("Players"):GetPlayers() >= 2
The second argument of table.insert, if you’re using the three-argument approach, is not a key, it’s an indice. Your script will throw an error if you use a non-numeric value here. You can still access it like an array, however the second argument can’t be whatever you please, it must be a number.
Awesome! Always learning things. Although this does make it seem even more useless. table.insert is extremely slow and I would never use it for any project. Updated my post to fix these issues!
There was no output errors, other than “Ro-Defender has eliminated 605 viruses in your games!”
Plus, I tried debugging from the previous comments, but that didn’t seem to work out,