Values on item use

Hello, I’m in the process of trying to figure out how to bind a tool/item to a value.

What I’m trying to achieve is essentially: You find an item, you use this item, and this item now grants it’s user a certain ability, and when given the ability, the player can reset and leave the game and will still keep that ability. Trying to make a personal battlegrounds game for practice for several things such as hitboxes, stuns, vfx, moves, CFrame, Raycasting, all of the above. I’ll be researching Datastore when I get to that, but I wanted to know if anybody could tell me how I could simply assign a permanent value to a player and then even if the player dies, have them still carry said value.

Any and all help means the world to me, so thank you if you read this far.

If you just create a StringValue/NumberValue/BoolValue etc. Instance and parent it on the player every value you set to that instance will stay whether the character dies or not and if you want to keep the value after player exits the game just save it using a Datastore. You can name that instance “ToolDamage” to know whate you’re reffering to. Other ways you can go about this is set an attribute at a tool, call it for exanoke “Damage” and when you need to change the value do:
tool:SetAttribute("damage", number)
This will stay for the entirety of the play session of a player and you can also save a value like that using Datastores.

1 Like

How would I go about making sure that this attribute is constantly parented to the player? OnCharacterAdded?

(I also tried “While true” and hoo thank god there’s a safety net. Almost nuked my studio)

Just parent the values to the player so they don’t reset on death

1 Like

You could save a Boolean value in a datastore. If you do not have experience with them, I’d suggest reading up or watching tutorials on the same.

1 Like

Yea I found out I’m going to NEED to learn datastores in order to get this working, so that’s exactly what I’ll do

if I parent a bool, string, or even attribute value to a player, dying resets anything that was put in, so I can’t simply do that, getting the value in there is easy, keeping it there is the annoying part.

Do you wish to keep it after the player leaves? Otherwise you can use a native table to achieve the same result.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.