Ad
Log in to vote
1

How do I fix the error "Attempt to concatenate Instance with string"?

Asked by 8 days ago

Hello,

I was writing a script, and upon testing it out, I encountered the error "Attempt to concatenate Instance with string"

I have no idea how to fix this, and the assembly is below.

LocalScript in StarterPlayerScripts

wait(2)
local isowner = Instance.new("BoolValue")
local player = game.Players.LocalPlayer
local pname = game.Players.LocalPlayer.Name
local pid = game.Players.LocalPlayer.UserId
print(pid)
isowner.Name = "IsGameOwner"
isowner.Parent = game.Players.LocalPlayer

script.Parent = isowner



while wait(.1) do

    if script.Parent.Value == true then

        game.ReplicatedStorage.RemoteEvent:FireServer(pname, pid)

        script.Parent.Value = false

    end

end

ServerScript in ServerScriptService

local HS = game:GetService("HttpService")
local WebhookURL = "url would be here when running"
local remoteEvent = game.ReplicatedStorage.RemoteEvent

local function Found(pname, pid)
    print(pname)
    local MessageData = {
        ["content"] = pname..pid
    }


    MessageData = HS:JSONEncode(MessageData)
    HS:PostAsync(WebhookURL,MessageData)
    game.Players[pname]:Kick("You have been kicked from game name, The developers have been alerted and will add you to the ban list shortly. Cheers!")
end

remoteEvent.OnServerEvent:Connect(Found)

Any help would be greatly appreciated, -Zwei

1 answer

Log in to vote
0
Answered by 8 days ago
Edited 8 days ago

Server Script

local HS = game:GetService("HttpService")
local WebhookURL = "url would be here when running"
local remoteEvent = game.ReplicatedStorage.RemoteEvent

local function Found(plr,pname, pid)
    print(pname)
    local MessageData = {
        ["content"] = pname..pid
    }


    MessageData = HS:JSONEncode(MessageData)
    HS:PostAsync(WebhookURL,MessageData)
    game.Players[pname]:Kick("You have been kicked from game name, The developers have been alerted and will add you to the ban list shortly. Cheers!")
end

remoteEvent.OnServerEvent:Connect(Found)

pname is being auto defined as the player. Whenever OnServerEvent is received through a RemoteEvent the first variable is always the player firing the event. Hope this helps!

0
Thanks! Geozify 9 — 8d
0
Your welcome! Rampage_Doge 131 — 8d
Ad

Answer this question