So i'm trying to make it so when you left click you punch and when you punch your strength stat goes up in leaderstats..It goes up but only on the client and i can't figure out how to script the OnServerEvent and the FireServer function in order to make this a server side script. I just started learning to script so try to explain in easily.
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local AnimationId = 5005123017
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://"..AnimationId
local AnimationTrack = Humanoid:LoadAnimation(Animation)
local function PunchAndAddStrength()
if not (AnimationTrack.Stopped) then return end
local Leaderstats = Player:WaitForChild("leaderstats")
local Strength = Leaderstats:FindFirstChild("Strength")
if (Strength) then
Strength.Value = (Strength.Value + 1)
end
AnimationTrack:Play()
end
Mouse.Button1Down:Connect(PunchAndAddStrength)

2 comments
Actually you can create the RemoteEvent from within the server script, and you can in fact name it just as anything else. It is actually encouraged to rename RemoteEvents if you have more than one.
Mhm.