1. BrickPlanet Forum
  2. Game & Scripting Discussion
  3. This script causes a huge error. . .
This script causes a huge error. . .
Ronaldinho
Level 2
Joined Feb 26th 2023
Posts 3
Posted Feb 28th 2023 at 9:00PM
So I made a script and It causes an error saying:

[Debug] Script error: Encountered an internal error, notify the brickplanet staff if the
problem persists. (System.NullReferenceException at Void
SetPlayerTeam(Brickplanet.Scripting.Api. PlayerProxy, System.String)

Lua (at [string "InternalStandardLua"]:40)

I'm making a script about touching a part and switching to that team. So the script is:

Leaderboard.CreateTeam('Barcelona', PartColor.new(0,0,255))


script.Parent.Touched:connect(function(hit)
Leaderboard.SetPlayerTeam('Barcelona')

end)

Is my script itself just incorrect somewhere but the engine isn't telling me or is it just an error because of the limitations of the engine or an internal bug like Hivemind said
PurpleSecretAgent
Level 8
Joined Nov 14th 2022
Posts 568
Posted Mar 2nd 2023 at 5:25AM
It makes sense.
Ronaldinho
Level 2
Joined Feb 26th 2023
Posts 3
Posted Mar 2nd 2023 at 9:15PM
It ain't roblox lua lol. I used the Brickplanet documentation that's where i got 'CreateTeam' from. Also im pretty sure you put the name of the team in that your wanting to create/set up and so not hex code because

"Leaderboard.CreateTeam('Barcelona', PartColor.new(0,0,255))"

Itself works and creates a team like i made it too

"script.Parent.Touched:connect(function(hit)"
that line refers to the part getting touched and what line it uses under after getting touched. That of course is

"Leaderboard.SetPlayerTeam('Barcelona')"

so idk whats wrong with it rlly please correct my code if your able too and see that it's incorrect
p1xat10n
Level 8
Joined Nov 12th 2022
Posts 65
Posted Mar 2nd 2023 at 10:02PM
Originally posted by Ronaldinho on Mar 2nd 2023 at 9:15PM
It ain't roblox lua lol. I used the Brickplanet documentation that's where i got 'CreateTeam' from. Also im pretty sure you put the name of the team in that your wanting to create/set up and so not hex code because

"Leaderboard.CreateTeam('Barcelona', PartColor.new(0,0,255))"

Itself works and creates a team like i made it too

"script.Parent.Touched:connect(function(hit)"
that line refers to the part getting touched and what line it uses under after getting touched. That of course is

"Leaderboard.SetPlayerTeam('Barcelona')"

so idk whats wrong with it rlly please correct my code if your able too and see that it's incorrect
you need to pass a player instance to setplayerteam
Charge
Level 5
Joined Nov 13th 2022
Posts 102
Posted Mar 6th 2023 at 11:46AM
hala madrid
Posted Mar 20th 2023 at 8:00PM
Leaderboard.CreateTeam('Barcelona', PartColor.new(0,0,255))

script.Parent.Touched:Connect(function(hit)
Leaderboard.SetPlayerTeam(hit, 'Barcelona')
end)

your function asks the leaderboard to put nothing in the team because you forgot to include the player in it which is hit

Search Forum

Thread Info

Replies
5
Views
52
Created Feb 28th 2023
Last Reply Mar 20th 2023