Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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!

2 comments

0

Thanks!

0

Your welcome!

This discussion is preserved as it was. New answers, comments, and votes are closed.