My tool script doesn't work

I am making a potion that boosts your strength. But there is a problem I’m trying to solve so that it would work, for some reason this script wont change the value of a certain numbervalue. (I cloned the potion from ReplicatedStorage and placed in the players backpack).
image

Any help is appreciated!

The issue is that you aren’t actually getting the player instance. You are treating it like it’s a child of the player when it isn’t.

Though you can get their character by calling the path down player, reversing it doesn’t work because it is really a child of Workspace.

To get the player from their character do

local plr = game.Players:GetPlayerFromCharacter(characterModelPathHere)

So the characterModelPath is basically the players character?

Yes, that takes the character as the input and I’m not entirely sure of your hierarchy so I just filled the blank with that.

The problem is you said I can’t backtrack and in order for me to get the players character i have to say tool.Parent.Parent.Character which doesn’t work.

When your tool is equipped, the parent changes from the backpack to the player’s character in the workspace. To get your player’s character, you would say script.Parent, while the tool is equipped. You may also want to check that your tool has “handle required” on false, if you want to use your tool without a handle.

Should I use localscripts because it still isn’t working.

You should use a RemoteEvent, since ServerScripts can’t access the Player’s Children (PlayerGui, Stats)
The LocalScript could be in StarterPlayerScripts

Does not work, this is the explorer is you want to see.

image

Could you be a bit more clear on what didn’t work, like if there are any errors? Also, just in case, don’t forget that the first parameter of OnServerEvent is always the Player who fired the RemoteEvent.

Using serverscripts doesnt work in tools, but localscript does and what I’m trying to do involves the serverscript, it doesn’t give errors, and it wouldn’t even print anything.

Hmm… this is odd. I usually make tools using both types of scripts in conjuction with remotes, and they work?

Do you mind showing the code of both scripts, so we can take a closer look on what might be wrong?

From what I know tool.Activated doesn’t fire from the server. Also check if your tool has ManualActivationOnly() that should be disabled.

Edit- If I’m right please give me a solution <3 :3

Found the solution, I’ve been cloning the tools using a local script, so it wouldn’t fire using serverscripts.