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

:lower() Assuming string is a Player?

Asked by 8 years ago

I have a localscript that send data to the server script and back, but I keep running into an issue. The server script keep reading my stringrequest as a Player, which makes no absolute sense to me.

Here is my code for the localscript;

function HIT_HANDLE(hit, dmg, tags)
    if hit.Parent:FindFirstChild("Humanoid") then
        dmg_event:FireServer("Damage", hit.Parent, hit.Parent:FindFirstChild'Humanoid')
        print'Done1!'
    end
end

function recieveInfo(Request, model, hum, common_functions)
    local request = Request:lower()
    if request == "damage" then
        hum:TakeDamage(110)
        PlaySound("Death")
        killeffect_module.Character(model, hum, common_functions, nil)
        print'Done3!'   
    end 
end

dmg_event.OnClientEvent:connect(recieveInfo)

And the code for my server script...

local dmg_event = game.workspace:FindFirstChild'DamageEvnt'

dmg_event.OnServerEvent:connect(function(Request, model, hum)
    local request = Request:lower()
    if request == "damage" then
        local common_functions = CommonKillEffectFunctions
        -- Fire all clients will fire every client that has the "OnClientInvoke" event connected.
        dmg_event:FireAllClients("damage", model, hum, common_functions)
        print'Done2!'
    end
end)

The error that will appear is; 19:24:55.397 - lower is not a valid member of Player, But I'm confused as to how the string "damaged" in the local script is being interpreted as a Player in the server script.

Thanks for reading!

Answer this question