This is my punch script (Animation), I'm trying to connect it to my exp value so that players get +1 exp when connecting with another humanoid, but I'm not sure where to start. The exp is an intvalue located in replicatedstorage.
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local dmg = true Mouse.KeyDown:connect(function(key) if key == "e" then -- change e to button to activate punch local an = script.Parent.Humanoid:LoadAnimation(script.Animation) an:Play() script.Parent.RightHand.Touched:connect(function(hit) if hit.Parent.Humanoid and dmg == true then -- i assume after the then statement a change in the exp would be put here hit.Parent.Humanoid:TakeDamage(game.ReplicatedStorage.StrengthStatValue.Value * 16) -- change 10 to amount of damage dmg = false wait(1) dmg = true end end) end end)
In order to make this work, I would move the strength value into an integer value assigned when the player joins the game. For example, this would go in severscriptservice -
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) local strength value = Instance.new(IntValue, char) -- add name, and value here end) end)
then, you can easily access the value by using a remote event from your local script to an exp managing script. After you play the animation, you could use RemoteEvent:FireServer to a script that adds +1 exp to the int value.
also, if you aren't sure how to use remote events, here's a helpful article - https://developer.roblox.com/en-us/api-reference/class/RemoteEvent
Hope this helps!