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

Why can't my script define if two different variables are the same thing?

Asked by 4 years ago
Edited 4 years ago

I am making a sword fight game and i made a 1v1 system for it. You write the name of the player you wanna fight, and you press the invite button. The invite button checks if the player name written in the textbox is an actual person, and fires a remote event to send the invite gui to that person. In the invite button, i'm trying to make it so that you can't invite yourself. However, the results are:

Try to invite myself - Function works

Try to invite someone else - Button has no response

Here's my try. (please note that this is only the part of the script that breaks.

script.Parent.MouseButton1Click:Connect(function()
    local playerInvited = game.Players:FindFirstChild(script.Parent.Parent.Box.Text)
    if playerInvited == nil then
        invalidPlayer() --  prewritten function
    elseif playerInvited.IsIn1v1.Value == true then
        AlreadyIn1v1()  --  prewritten function
    elseif game.ReplicatedStorage.Ongoing1v1 == true then
        WaitFor1v1ToFinish()  --  prewritten function
    elseif playerInvited ~= nil and playerInvited.IsIn1v1.Value == false then
    if  playerInvited.Name ==  not game.Players.LocalPlayer.Name then   
    game.ReplicatedStorage.SendInvite:FireServer(playerInvited,player)
        script.Parent.Text = "Invite sent!"
        wait(2)
            script.Parent.Text = "Send Invite"  
        elseif playerInvited.Name == game.Players.LocalPlayer.Name then
            AttemptToInviteYourself() --  prewritten function, this is the part that breaks
    end     
    end 
end)

I have tried to fix this many times, but all of my attempts failed.

0
EVERYONE: I changed the bug! The original bug was incorrect. The real bug is that the invite button has no response to an actual player name. MikkelTheRich -2 — 4y

Answer this question