My punching script only works in edit mode for some reason. I can't seem to find what part of the script is messing things up. I know that scripts work differently in edit mode and play mode, but I still can't figure out why my script specifically won't work. Any help is appreciated!
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local Char = player.Character
local Humanoid = Char:WaitForChild("Humanoid")
local Trail = game.Workspace.Trail:Clone()
local Trail2 = game.Workspace.Trail:Clone()
local animations = {1877306614,1877291193}
local function Punch(plr)
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
Trail.Parent = Char.HumanoidRootPart
local attachment0 = Instance.new("Attachment", Char.RightHand)
attachment0.Name = "TrailAttachment0"
local attachment1 = Instance.new("Attachment", Char.RightUpperArm)
attachment1.Name = "TrailAttachment1"
Trail.Attachment0 = attachment0
Trail.Attachment1 = attachment1
wait(0.5)
Trail:Remove()
elseif picked == 2 then
dmgScript.Parent = Char.LeftHand
Trail2.Parent = Char.HumanoidRootPart
local attachment0 = Instance.new("Attachment", Char.LeftHand)
attachment0.Name = "TrailAttachment0"
local attachment1 = Instance.new("Attachment", Char.LeftUpperArm)
attachment1.Name = "TrailAttachment1"
Trail2.Attachment0 = attachment0
Trail2.Attachment1 = attachment1
wait(0.5)
Trail2:Remove()
end
dmgScript.Disabled = false
wait(0.4)
dmgScript:Destroy()
end
Mouse.Button1Down:connect(function()
print("yup it worked")
Punch()
end)
^That's inside of a LocalScript inside of StarterGui
script.Parent.Touched:Connect(function(hit)
local char = hit.Parent
local hum = char:FindFirstChild("Humanoid")
if hum and char.Name ~= script.Parent.Parent.Name then
hum.Health = hum.Health - script.Dmg.Value
script.Disabled = true
wait(0.5)
script.Disabled = false
end
end)
^That's inside of a Server script inside of the script above
^And there's an IntValue inside of the script above

2 comments
Can you describe what happens when it "doesn't work"?
Literally nothing happens when I click