I'm curious as to why some scripts only work in edit mode, and not when you publish it. I've had this problem before, and was given a solution, but I still don't understand why it does this. I've heard that it has something to do with the 'client' and the 'server' and stuff like that, but I don't truly understand what I keep doing wrong. Some justification is appreciated.
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local Char = player.Character
local Humanoid = Char:WaitForChild("Humanoid")
local animations = {1877306614,1877291193,01895620990}
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
elseif picked == 2 then
dmgScript.Parent = Char.LeftHand
elseif picked == 3 then
dmgScript.Parent = Char.LeftFoot and Char.LeftLowerLeg
end
dmgScript.Disabled = false
wait(0.4)
dmgScript:Destroy()
end
Mouse.Button1Down:connect(function()
print("yup it worked")
Punch()
end)
This is inside 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)
This is inside a script inside of the script above ^^^
There is also an Int value inside of the normal script. ^^^

4 comments
in edit mode, there is no difference between Server and Local.
In edit mode, it can only simulate server and local while everything is still local. So server intended functions will not work in studio
Thanks for the quick replies! So basically in edit mode, server scripts act like localscripts?
not exactly, but whats happening is that on a normal on-line game, the "Server" wouldn't be local. In studio, the "Server" is local. Local scripts and regular scripts still act different, but its the local server that makes things sometimes work in studio but not in-game