I have a tool that is supposed to give the player stats when activated, however there are no errors and it doesn't seem to be working. The problem I see is at
script.Parent.Activated:Connect(function()
because nothing is printed after that line of code. Any help would be appreciated!
By the way, I've tried this with both filtering enabled on and off, and with a local script and a normal script. All it contains is just a tool in starterpack with a script as the tool's child.
local player = script.Parent.Parent.Parent print("line 2") db = false print("line 4") script.Parent.Activated:Connect(function() if db == false then print("line 6") db = true local randomm = math.random(1,2) print(1) if randomm == 1 then print("1") player.Stats.Strength.Value = player.Stats.Strength.Value + 1 end if randomm == 2 then print("2") player.Stats.Strength.Value = player.Stats.Strength.Value + 2 end end wait(1) print("db = false") db = false end)
I don't see any problems, if it's in a tool, make sure the tool either has a child named "Handle" or change it so that it doesn't require a handle. Your script looks fine.
If the player has to equip the tool to use it, then it is located within their character at the time of activation. If their stats are located in the player, then a tool in the character would not be able to access the stats through a string of parents.
If you change
local player = script.Parent.Parent.Parent
to
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
then the rest of the script should work as it is.