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

attempt to concatenate Instance with string line 11?

Asked by 4 years ago
Edited 4 years ago
game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(Message)
        local SplitMessage = Message:split(" ")
        if SplitMessage[1] == "/rank" then
            print("Command Is Correct")
            local NameOfPlayerToGiveRankTo = SplitMessage[2]
            local PlayerToGiveRankTo = game.Players:FindFirstChild(NameOfPlayerToGiveRankTo)
            local RankName = Message:split(NameOfPlayerToGiveRankTo)[2]

            PlayerToGiveRankTo.leaderstats.Rank.Value = RankName
            print(player.Name.." changed "..PlayerToGiveRankTo.."'s rank to "..RankName.."!")
        end
    end)
end)

This is the client side notification

EventsFolder.NotifySender.OnClientEvent:Connect(function(PlayerToGiveRankTo, RankName)
    wait(0.5)
    game.StarterGui:SetCore("ChatMakeSystemMessage",{
        Text = "You have changed ".. PlayerToGiveRankTo .."'s rank to ".. RankName .."!";
        Font = Enum.Font.SourceSansBold;
        Color = Color3.fromRGB(85,255,0);
        TextSize = 18;
    })
end)
0
For Client Side Line 4 doenst work Philipceo90 18 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

"PlayerToGiveRankTo" is an Instance (Player) which can be seen in line 07. You cannot concatenate (which in simpler terms means to "put together" pieces to form one string) an Instance with a string.

It seems you are trying to put the players username in the message, so change line 11

print(player.Name.." changed "..PlayerToGiveRankTo.."'s rank to "..RankName.."!")

to

print(player.Name.." changed ".. PlayerToGiveRankTo.Name .."'s rank to "..RankName.."!")
0
Still doesnt work Philipceo90 18 — 4y
0
For the client side, also do "PlayerToGiveRankTo.Name" Slydexic 20 — 4y
Ad

Answer this question