Can someone tell me why this script doesnt turn the player into my custom character?
So I have been trying to make a Piggy like a game but my code just won't cooperate I have made a script called game logic and 2 module scripts in it called RoundModule and EventHandling can you tell me why the code doesn't allow the player to become my custom character? here is the game logic script
01 | local Round = require(script.RoundModule) |
03 | local chosenChapter = Round.SelectChapter() |
05 | local clonedChapter = chosenChapter:Clone() |
06 | clonedChapter.Name = "Map" |
07 | clonedChapter.Parent = game.Workspace |
10 | for i, v in pairs (game.Players:GetPlayers()) do |
11 | if not v:FindFirstChild( "InMenu" ) then |
12 | table.insert(Contestants,v) |
16 | local chosenPiggy = Round.ChoosePiggy(Contestants) |
18 | for i, v in pairs (Contestants) do |
20 | if v = = chosenPiggy then |
21 | table.remove(Contestants,i) |
23 | game.ReplicatedStorage.ToggleCrouch:FireClient(v, true ) |
27 | Round.DressPiggy(chosenPiggy) |
here is RoundModule script
03 | local status = game.ReplicatedStorage:WaitForChild( "Status" ) |
04 | function module.intermisiion(length) |
06 | status.Value = "Next round starts in " ..i.. " seconds" |
11 | function module.SelectChapter() |
12 | local rand = Random.new() |
13 | local chapters = game.ReplicatedStorage.Chapters:GetChildren() |
14 | local chosenChapter = chapters [ rand:NextInteger( 1 ,#chapters) ] |
19 | function module.ChoosePiggy(players) |
21 | local Rand = Random.new |
23 | local chosenPiggy = players [ Rand:NextInteger( 1 ,#players) ] |
27 | function module.DressPiggy(piggy) |
28 | local character = game.ServerStorage.Sasuke:Clone() |
29 | character.Name = piggy.Name |
30 | piggy.Character = character |
31 | character.Parent = game.workspace |
the event handling one has no code right now so I won't show it, and the errors that show are
15:48:32.758 - ServerScriptService.Game Logic.RoundModule:23: attempt to index function with 'NextInteger',and 15:48:32.759 - Script 'ServerScriptService.Game Logic', Line 16 can you tell me what this problem is?