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

I used Remote Events on my Punching Script But it STILL Works in studio but not in the server!?

Asked by
Tizzel40 243 Moderation Voter
5 years ago

i made a punch script with remote events and it doesn't work it the real game

The local Script in Starter Gui

local remote = Instance.new("RemoteEvent",game.Workspace)
remote.Name = "PunchEvent"
local use = false
local uis = game:GetService("UserInputService")
local play = game.Players.LocalPlayer
local char = play.Character or play.CharacterAdded:wait()
local humanoid = char.Humanoid

uis.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.E and use == false then
        use = true
        local punch = humanoid:LoadAnimation(script.Animation)
        remote:FireServer()
        punch:Play()
        wait(1)
        use = false
    end
end)

The Normal Script in Workspace...

local punche = game.Workspace:WaitForChild("PunchEvent")

punche.OnServerEvent:Connect(function(player, use)
    local char = player.Character or player.CharacterAdded:wait()
    local hum = char.Humanoid
    local rightp = char:WaitForChild("RightHand")
    local hitall = false
    rightp.Touched:Connect(function(hit)
        if hit and hit.Parent:FindFirstChild("Humanoid") and hitall == false then
            hitall = true
            hit.Parent.Humanoid:TakeDamage(15)
        end
    end)


end)

Did I get Something mixed up?

0
Try putting your RemoteEvent into Replicated Storage, not the workspace. Pojoto 329 — 5y
0
Parent argument to Instance.new is deprecated, and :wait() is also deprecated. User#19524 175 — 5y
0
Parent argument still works. LinKiNSpitZ 22 — 5y
0
However, it's not good for performance and a bad practice. Pojoto 329 — 5y

Answer this question