Having trouble making a script that gives the player Unlimited sprint on player spawn.
-
This is my first time actively trying to write and use a script, so I'm brand new to this. Not exactly sure what it is I'm doing wrong. I've gotten the game to load and the bootstrapper is telling me that it's able to execute the script (it doesn't kick me out of the game or anything). But the player sprint is still default, in-game. They sprint for a few seconds and then stop, as usual.
Anyone know how I can fix this?
This is the script.
-
You have to call your function on the player entity. Like welcome.
-
Xerxes Thank you. Could you give me an example?
-
Unfunny_Umi "like welcome" so just do the same
In code there is always two steps:- Declaring a piece of code to make it available
- Calling that piece of code (function) to actually use it
Right now you're declaring the
unlimited_sprint
function, it exists, but it is never called/used on any entity.
It just sits there but it's never used. Declaring a function doesn't do anything more than making it available.You added
thread unlimited_sprint()
but you don't thread on any object.
You need to call the function on something (the level, a player etc.)So move this below player thread welcome() like Xerxes said.
for (;;) { level waittill("connecting", player); player thread welcome(); player thread unlimited_sprint(); }
This way you are saying "when a player connects thread the
unlimited_sprint
function on him on that particular player -
Resxt You guys are the best. Genuinely, thank you so much.
I got it working! Much Love! -
Unfunny_Umi hey I've tried using your script but it did not work here is the script can you tell if it's correct I
have no experience with codinginit()
{
thread unlimited_sprint();
for (;;)
{
level waittill("connecting", player);
player thread welcome();
player thread unlimited_sprint();
}
}unlimited_sprint()
{
self waittill("spawned_player");
self setperk("specialty_unlimitedsprint");
}
welcome(){
self endon("disconnect");
self waittill("spawned_player");}
-
Eleven111 the guy was asking for help coz his script didn't work so copy pasting it will obviously not work. Read the answers
-
Resxt I understand but you helped him with the code and he said it worked for him that's why I was asking him about it, because I tried using the code and I added that correct code that u mentioned and still did not work. any help would be appreciated
-
Eleven111 the code you've shown does not contain the modified code
-
would you please help with the code. I'm illiterate when it comes to coding
-
Eleven111 I myself was confused from the jump as to how OP got the beginning code he posted. Most .gsc contain three main functions and they call like such.
init() { level thread onPlayerConnect(); } onPlayerConnect() { for(;;) { level waittill("connected", player); //waits until you are connected to the server, before you spawn in. player thread onPlayerSpawned(); } } onPlayerSpawned() { self endon("disconnect"); level endon("game_ended"); for(;;) { self waittill("spawned_player"); //anything after this happens after you spawn in. You cannot set perks on a player that is not spawned in yet. } }
Simply set the perk after said player spawns in. That's really where your problem lies.