17:09:23.898 ServerScriptService.Script:6: attempt to index nil with 'Name' - Server - Script:6
Code Is
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ClientForWeightLift = ReplicatedStorage:WaitForChild("ClientForWeightLift")
ClientForWeightLift.OnServerEvent:Connect(function(player, Tool)
local Tool = script.Parent
local Character = game.Workspace:WaitForChild(game.Players.LocalPlayer.Name)
local LiftingAnimation = Character:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("Lifting"))
local Player = game.Players:GetPlayerFromCharacter(Character)
if Player then
Player.leaderstats.Strength.Value += 1
LiftingAnimation:Play()
end
end)
About What Making
Im making A Weight, that gives strength everytime A player, Activates/Clicks The mouse It'll Give Strength and do an animation.
What Have I Not Finish
I have, not finished my strength leaderstats script.
In your if Player then conditional check, youâre checking if the Playerâs Name is a Character Model which wouldnât be valid to the function itself
I also just realized youâre defining Tool again, even when you referenced the Tool parameter on your OnServerEventâŚ? Why?
Could you try this at least?
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ClientForWeightLift = ReplicatedStorage:WaitForChild("ClientForWeightLift")
ClientForWeightLift.OnServerEvent:Connect(function(player, Tool)
local BaseTool = script.Parent
local Character = player.Character
local LiftingAnimation = Character:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("Lifting"))
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
Player.leaderstats.Strength.Value += 1
LiftingAnimation:Play()
end
end)
Edit: I just realized youâre also re-defining the player, when you could just reference it with the player parameter provided by OnServerEvent