Answered by
4 years ago Edited 4 years ago
Instead of using a local script, try using a normal script inside of StarterPlayerScripts.
To use this effectively, you may have to define the player using different methods, as you cannot use Players.LocalPlayer.
How I do this is that I would search for the player using the script's parent's name.
Here is an edited piece of code:
01 | local plrs = game:GetService( "Players" ) |
02 | local plr = plrs:FindFirstChild(script.Parent.Name) |
03 | local chr = plr.Character |
04 | local hum = chr:WaitForChild( "Humanoid" ) |
05 | local leaderstats = plr.leaderstats |
06 | local animation = Instance.new( "Animation" ) |
08 | local animationTrack = hum:LoadAnimation(animation) |
11 | local RS = game:GetService( "ReplicatedStorage" ) |
12 | local AddStrength = RS:WaitForChild( "AddStrength" ) |
13 | local tool = game.ReplicatedStorage [ "Strength+1" ] :Clone() |
14 | tool.Parent = plr.Backpack |
19 | tool.Activated:Connect( function () |
22 | animationTrack.Looped = true |
25 | animationTrack.Looped = false |
26 | AddStrength:FireServer(leaderstats) |
Put this script in a NORMAL SCRIPT inside of StarterCharacterScripts, NOT A LOCAL SCRIPT