Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make my Sword Attack script works in the published server?

Asked by 6 years ago

On the studio, it's working, but when I published the game, nothing happens when the sword hits the NPC.

Here's the script:

PlayerName = script.Parent.Parent.Parent.Name
Tool = script.Parent
Damage = script.Parent.Settings.Damage
local ButtonPressed = false

Tool.Equipped:connect(function(Mouse)
    Mouse.Button1Down:connect(function()
----------------------------------------------------------------------  
        script.Parent.DamagePart.Touched:connect(function(hit)
            if not ButtonPressed then
                --is it not pressed?
                ButtonPressed = true
                print("Here")
                -----------------------
                if hit.Parent then
                local human = hit.Parent
                hum = human:FindFirstChild("Settings")
                if hum then
                    hum.HP.Value = hum.HP.Value - script.Parent.Settings.Damage.Value

                    x = hit.Parent:FindFirstChild("Fighters")
                    y = x:FindFirstChild(PlayerName)
                    if not y then
                        z = Instance.new("IntValue")
                        z.Parent = x
                        z.Name = PlayerName
                    end

                end

                wait(1)
                end
                ------------------------
                ButtonPressed = false
            end
        end)
---------------------------------------------------------------------
    end)
end)
0
Is this a server or a local script? User#20388 0 — 6y
0
Normal Script, not local FlonexVorry 28 — 6y
0
Can you reference MouseEvents from Server under FE? idk Pejorem 164 — 6y

Answer this question