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

Sword Script Will Not Damage Players/AI, Wont Even Call The Remote?

Asked by
LuaDLL 253 Moderation Voter
5 years ago

Local Script Calling Remote:

Tool.Handle.Touched:Connect(function(hit)
    if Swinging and Equipped then
        local hitParent = hit.Parent
        if hit.Parent:FindFirstChildWhichIsA("Humanoid") and hit.Parent.Name ~= Player.Name then
            Remote:FireServer("R??????o????????????m?????????????a????????n??????????????",hitParent)
        end
    end
end)

Script Handling Remote:

local Tool = script.Parent
local Remote = Tool.Remote

local Damage = 6
local Crit = (Damage*2)

function getCrit()
    local Ran = math.random(1,12)
    local Ran2 = math.random(1,12)
    if Ran == Ran2 then
        return true
    else
        return false
    end
end

function damage(Hit)
    local Humanoid = Hit:FindFirstChildWhichIsA("Humanoid")
    local IsCrit = getCrit()
    local Dmg = nil
    if IsCrit then
        Dmg = Crit
    else
        Dmg = Damage
    end
    Humanoid:TakeDamage(Dmg)
end

Remote.OnServerEvent:Connect(function(key,Hit)
    if key == "R??????o????????????m?????????????a????????n??????????????" then
        damage(Hit)
    end
end)

1 answer

Log in to vote
1
Answered by 5 years ago

It may be that the remote fetches the player for the first variable so instead replace line 29 with

Remote.OnServerEvent:Connect(function(p, key, hit)
0
Oh yea i forgot about remotes fetch the player first. :facepalm: thank you it works now! LuaDLL 253 — 5y
0
no problem :) coolguyjeremy1213 24 — 5y
Ad

Answer this question