Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I access userdata within a Tool?

Asked by 4 years ago

I made a weapon that holds a basedamage value. I also made a skill-system that allows you to spend Points on Stats like Damage, Speed and Health. How can I access the Stats inside the Local Player with a "normal" script inside my weapon? The stats object inside of the player is in ReplicatedStorage and gets assigned to the player once they enter.

local BaseDamage = script.Parent.BaseDamage.Value
local AddedDamage = --[[ This is the problem. How do I access the stats of the Player? I tried it with game.Players.PlayerAdded, but I only get the Value "nil" for the Damage value inside of stats, but it should be 300.
]]

As always, thanks in advance!

0
Tool.Parent will be player's character after Activated is fired. then use game.Players:GetPlayerFromCharacter(Tool.Parent) to get player Mr_m12Ck53 105 — 4y
0
Thanks! Please write this as an answer so I can accept it! User#34929 0 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Tool.Activated:Connect(function()
    local char = Tool.Parent -- Here is the character
    local plr = game.Players:GetPlayerFromCharacter(char) -- Here is the player
end)
Ad

Answer this question