Maybe i messed up my script and dont know how to fix it {Updated}

Hello everyone, first things first i need to apologize for putting the wrong Category in my last topic, im sorry!
So… yesterday my Script for my experience bar stopped working, i dont know how to fix it, Any help?
image b

PS: the whole situation:

1 Like

the player variable is probably nil if you ready output plus why are you checking the players name

1 Like

thanks, also i was cheking to see if the Player who killed was the same who got the EXP

1 Like

Oh wait my mistake I Thought it said player.Name == player.Name

1 Like

Show the part in which you are firing this bindable event please.

2 Likes

For conventional purposes, it’d probably be cleaner to have the player sent as the first argument rather than the amount. Furthermore, there’s not enough code provided to address the issue. Please show the actual code that’s experiencing the error.

its on the ServerScriptService

The script that fires the event is the culprit. It’s passing nil instead of the player instance. To help you any more we need to see the script that calls game.ServerStorage.GiveExp:Fire(...)

image
im using basically this

Your not sending the player
Game.ServerStorage.GiveExp:Fire(game.Players.LocalPlayer)

All that game.ServerStorage.GiveExp:Fire(...) does is pass anything you type in the order it is written to whatever function is connected to it’s event. The function you have connected expects an amount and a player value passed in that order, but you’re not sending anything when you’re firing it.

As colbert2677 mentioned earlier it’s better to pass the player first because that’s how remote events and functions work. It keeps it more consistent but it’s not necessary.

Where is the script firing the bindable Bindable:Fire() <-- that portion. This could let me better visualize what you’re dealing with.

That was a close call you saw but bindables cannot be used to communicate between server and client so what you suggested will not work.

@TaresuDesu The problem is that you are trying to communicate between server and client using a bindable event (which wont work). Instead, I suggest using the event made to communicate between server and cleint RemoteEvent . You can mark it solved but however if you seem to be having issues using RemoteEvent make sure to reply with your issue.

The fact that his top function is firing and erroring out means that he is using a script and not a local script. If it was a local script it wouldn’t be able to call the bindable because it’s in ServerStorage.

1 Like

Um… no? image
Based on this image, I can tell that the script that is firing is placed inside the character as he is doing local hum = script.Parent:WaitForChild("Humanoid") Yea it’s not a big mistake but that is the mistake at the time being since he is trying to communicate to the server script placed in serverscriptservice from inside the character model.

Actually, there are 2 scripts, the local one is to fire the Exp and the other other one is on the ServerScriptService, sorry to not say this first

Yea in either cases If you want to get the cue to update the experience value from the client you need to use a remote event to communicate the change.

@Vain_p

LocalPlayer can’t be used on the server, hence local. This is all being done from a server script, which has been clarified a few times throughout the thread.


@HumbledDragon

It’s a server script communicating with another server script. The design choice is intentional. LocalScripts won’t error if they fire an event which a server script is listening on and vice versa. The error is clearly outlined in OP: it’s attempting to index a nil value.

Everything you said here is moot. Please read the thread and the provided information before replying. The function is firing, I don’t know what you mean by “no”. The error is because a parameter is nil. Scripts don’t error from firing events.

The script being in the character is moot to mention. A script in a character doesn’t implicitly mean its a LocalScript. Server scripts are also capable of running in characters. Character server scripts are capable of communicating with ServerScriptService scripts.

Please do some research and testing. These are false facts with no substantial basis.

Good way to get exploited. A remote is unnecessary here, the client isn’t in control of any information flow. The server is checking when a player dies and is accordingly informing another server script to perform an action via a BindableEvent.

This might be off topic, but on in the PlayerRemoving event you added a GetAsync() rather than a SetAsync().