Long post and I'm still new to scripting. So,
I was following a tutorial (Link)(Might be an outdated method) I decided to follow this tutorial to make a damage system. He puts the Remote Function in the Local script as a child he uses and he adds a normal script as a child of the Remote Function.
Followed it . It didn't do any damage, so I thought to change the script to use a Remote Function in the Replicated Storage.
Local Script works fine and no error, but the script I used to activate the Remote function can no long use LocalPlayer. Is there a replacement for this Also please let me know if I need to change the way I need to do this.
local rs = game:GetService("ReplicatedStorage")
local punching = rs:WaitForChild("ThePunch")
Enabled = true
punching.OnServerEvent:Connect(function(Action, Player, numb1)
local player = game.Players.LocalPlayer
local char = player.Character
if Enabled == false then
return
end
if Action == "Combat" then
for i, v in pairs(workspace:children()) do
if v:FindFirstChild("Humanoid") and v:FindFirstChild("HumanoidRootPart") and v:FindFirstChild("Debounce") and v ~= char then
if (v.HumanoidRootPart.Position-char.HumanoidRootPart.Position).magnitue <= 5 then
v.Humanoid:TakeDamage(5)
end
end
end
end
end)

2 comments
Hey thanks for the reply but is there a way you can show me what you mean?
Sorry for the late response, on line 7 you write " local player = game.Players.LocalPlayer" which a server script cant recognize. Instead, anywhere where you would have used that variable on line 7, you instead use the parameter called "Player" which is the second parameter of the function on line 6. Basically, remove line 7 and change line 8 to "local char = Player.Character" capital P