Im trying to make it so when you punch you deal damage, i have the local script i just need help with the server script to send the damage to the server but i have no idea on what im doing.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Punch = ReplicatedStorage:WaitForChild("Punch") local player = game.Players.LocalPlayer local str = player.leaderstats.strength Punch.OnServerEvent:Connect(function(player) player.Parent.Humanoid:TakeDamage(str) end)
This is what i have so far, im getting the error "attempt to index nil with 'leaderstats' i want to make it so the more strength you have that's the amount of damage you do so if u earned 100 strength you do 100 damage, etc.
If the script you put is the server script, you can't access LocalPlayer from a serverside script. Has to be called from a local script only. Alternative way of getting the player is game.PlayerAdded
Thanks for the help, i've gotten it now heres the updated script
game.Players.PlayerAdded:Connect(function(player) end) game.ReplicatedStorage.Punch.OnServerEvent:Connect(function(player, humanoid) local str = player.leaderstats.strength.Value humanoid:TakeDamage(str) end)