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

Why isn't it working to transfer a hit function to a remoteevent? [UPDATED]

Asked by
DevingDev 346 Moderation Voter
6 years ago
Edited 6 years ago

So i am woundering why isn't this working to transfer this hit function from a local script to a server script with a remote event.

Local Script:

mouse.Button1Down:connect(function()
    local value = Stats[Equipped]["Cooldown"]
    if not cooldown and not Attacking then
        local playAnim = char.Humanoid:LoadAnimation(anim)
        playAnim:Play()
        if not cooldown then
            Attacking = true
        end

        if Class == "Axe" then
            local weapon = ActiveWeapon:FindFirstChild(Equipped)
            if Attacking == true then
                weapon["Blade"].Touched:connect(function(hit)
                    if hit.Parent:FindFirstChild("Humanoid") then
                        if not deb then
                            deb = true
                            Remotes["TakeDamage"]:FireServer(hit, Stats[Equipped]["Damage"])
                        end
                    end
                end)
            end
        end

        -- WEAPON COOLDOWN SYSTEM --
        for i = value,0,-1 do
            cooldown = true
            wait(.65)
        end
        cooldown = false
        Attacking = false
        deb = false
    end
end)

Server Script:

Remotes["TakeDamage"].OnServerEvent:connect(function(hit, dmg)
    print(hit.Parent.Name)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent:FindFirstChild("Humanoid"):TakeDamage(dmg)
    end
end)
0
Why do you need a remote event... just use the server script User#17125 0 — 6y
0
Cause i need it to fire when you click the mouse DevingDev 346 — 6y
0
Please provide more context, Any errors? How exactly is it not working. no damage is being outputted, the event isn't even firing? Also, show us the full local script, where you define the remoteevent. Also, use :Connect instead of :connect User#17125 0 — 6y
0
Whats the differense between :connect and :Connect? DevingDev 346 — 6y
View all comments (2 more)
0
There are 2 differences. 1) They are capitalized differently 2) :connect is deprecated, and :Connect is not. hiimgoodpack 2009 — 6y
0
Using :Connect will appease hiimgoodpack so he doesn't get mad at you. Viking359 161 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

you shouldn't need a remoteevent if i'm interpreting this correctly.

weapon["Blade"].Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        if not deb then
            deb = true
            hit.Parent.Humanoid:TakeDamage(dmg)
            wait(2)
        end
        deb = false
    end
end)
Ad

Answer this question