Here's the script (btw its in a tool as a local script) what it's meant to do is when you press q and you have a certain amount of a stat then it will trigger a punch animation
math.randomseed(tick())
local player = game.Players.LocalPlayer
local char = game.Workspace:FindFirstChild(player.Name)
local RS = game.ReplicatedStorage
local StatsFolder = game.ReplicatedStorage:WaitForChild("StatsFolder")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punchEvent = Instance.new("RemoteEvent", ReplicatedStorage)
punchEvent.Name = "PunchEvent"
local animations = {1083459730, 1083486387} --Must be changed because the animations made by me won't work for other people than me. Make your own and insert the id's here, separated by commas.
local function onPunchFired(player)
if RS.StatsFolder:FindFirstChild(char.Name).Fat.Value > 10 or RS.StatsFolder:FindFirstChild(char.Name).Muscle.Value > 10 then
local humanoid = char.Humanoid
local animation = Instance.new("Animation")
local picked = math.random(1, #animations)
animation.AnimationId = "http://roblox.com/asset/?id="..animations[picked]
local animTrack = humanoid:LoadAnimation(animation)
animTrack:Play()
local dmgScript = script.DmgScript:Clone()
if picked == 1 then
dmgScript.Parent = char.RightHand
elseif picked == 2 then
dmgScript.Parent = char.LeftHand
end
dmgScript.Disabled = false
wait(0.4)
dmgScript:Destroy()
end
end
punchEvent.OnServerEvent:Connect(onPunchFired)
---------------

10 comments
You know, you can't dump us in a random city and expect us to know our way around. Guess what, you can't go give someone your code and leave and expect them to know what it does!
well im sorry, thisis my first time using this website and asking for help, so please explain to me, in a professional manner, how to improve this question so I don not make the same mistake i created again.
i did.........................
Ok there, are you able to help me?
Imagine if the character hasn't loaded yet......
ok i understand now, do you know how to make the script wait for the character to load?
Instead of doing game.Workspace:FindFirstChild(player.Name), just simply do player.Character
http://wiki.roblox.com/index.php?title=RBXScriptSignal#Wait
thank you so much!!! D?mo arigat?gozaimashita!
I noticed that you're trying to use OnServerEvent with LocalPlayer. You cannot use OnServerEvent on a LocalScript, and you can't use LocalPlayer on a regular (server) script. You're going to be in for a surprise when you test this in an actual server.