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

Attempt to concatenate instance with string?

Stack Begin  -  Studio Script 'ServerScriptService.Script', Line 50  -  Studio  -  Script:50 Stack End  -  Studio

Script:

local name = "Player"

local serverScriptService = game:GetService("ServerScriptService")
local chatServiceModule = require(serverScriptService:WaitForChild("ChatServiceRunner").ChatService)
local nameColors = {
	Color3.fromRGB(253, 41, 67), -- BrickColor.new("Bright red").Color,
	Color3.fromRGB(1, 162, 255), -- BrickColor.new("Bright blue").Color,
	Color3.fromRGB(2, 184, 87), -- BrickColor.new("Earth green").Color,
	BrickColor.new("Bright violet").Color,
	BrickColor.new("Bright orange").Color,
	BrickColor.new("Bright yellow").Color,
	BrickColor.new("Light reddish violet").Color,
	BrickColor.new("Brick yellow").Color,
}

local function getNameValue(name)
	local value = 0
	for index = 1, #name do
		local cValue = name:sub(index, index):byte()
		local reverseIndex = #name - index + 1
		if #name % 2 == 1 then
			reverseIndex = reverseIndex - 1
		end
		if reverseIndex % 4 >= 2 then
			cValue = -cValue
		end
		value = value + cValue
	end

	return value
end

local speaker = chatServiceModule:GetSpeaker(name)
if not speaker then
	speaker = chatServiceModule:AddSpeaker(name)
	speaker:SetExtraData("NameColor", nameColors[getNameValue(name) % #nameColors + 1])
	speaker:JoinChannel("All")
end
game.ReplicatedStorage.FireChat.OnServerEvent:Connect(function(player, hour, min)
local Country = game:GetService("LocalizationService"):GetCountryRegionForPlayerAsync(player)
wait(2)
speaker:SayMessage("I know where you live", "All")
wait(3)
speaker:SayMessage("I am coming to your house", "All")
wait(3)
speaker:SayMessage("I know you live in ", Country.. "All")
wait(3)
speaker:SayMessage("I know your IP is: ", math.random(1,200).."."..math.random(1,200)..".".. ".1.1.".. "All")
wait(3)
speaker:SayMessage("I know your local time is ", hour.. ":".. min.. "All")
end)

LocalScript:

local player = game.Players.LocalPlayer
local playertime = os.date("*t", os.time())
local hour, min = playertime.hour, playertime.min
game.ReplicatedStorage.FireChat:FireServer(player, hour, min)

1 answer

✓ Accepted answer

the onserverevent already receives the player variable by default

local player = game.Players.LocalPlayer
local playertime = os.date("*t", os.time())
local hour, min = playertime.hour, playertime.min
game.ReplicatedStorage.FireChat:FireServer(hour, min)

so in your case it was

OnServerEvent:Connect(function(player, player, hour, min)

and thus you concat an instance with a string

this is what your code should be

local player = game.Players.LocalPlayer
local playertime = os.date("*t", os.time())
local hour, min = playertime.hour, playertime.min
game.ReplicatedStorage.FireChat:FireServer(hour, min)
local name = "Player"

local serverScriptService = game:GetService("ServerScriptService")
local chatServiceModule = require(serverScriptService:WaitForChild("ChatServiceRunner").ChatService)
local nameColors = {
    Color3.fromRGB(253, 41, 67), -- BrickColor.new("Bright red").Color,
    Color3.fromRGB(1, 162, 255), -- BrickColor.new("Bright blue").Color,
    Color3.fromRGB(2, 184, 87), -- BrickColor.new("Earth green").Color,
    BrickColor.new("Bright violet").Color,
    BrickColor.new("Bright orange").Color,
    BrickColor.new("Bright yellow").Color,
    BrickColor.new("Light reddish violet").Color,
    BrickColor.new("Brick yellow").Color,
}

local function getNameValue(name)
    local value = 0
    for index = 1, #name do
        local cValue = name:sub(index, index):byte()
        local reverseIndex = #name - index + 1
        if #name % 2 == 1 then
            reverseIndex = reverseIndex - 1
        end
        if reverseIndex % 4 >= 2 then
            cValue = -cValue
        end
        value = value + cValue
    end

    return value
end

local speaker = chatServiceModule:GetSpeaker(name)
if not speaker then
    speaker = chatServiceModule:AddSpeaker(name)
    speaker:SetExtraData("NameColor", nameColors[getNameValue(name) % #nameColors + 1])
    speaker:JoinChannel("All")
end
game.ReplicatedStorage.FireChat.OnServerEvent:Connect(function(player, hour, min)
local Country = game:GetService("LocalizationService"):GetCountryRegionForPlayerAsync(player)
wait(2)
speaker:SayMessage("I know where you live", "All")
wait(3)
speaker:SayMessage("I am coming to your house", "All")
wait(3)
speaker:SayMessage("I know you live in " ..Country, "All")
wait(3)
speaker:SayMessage("I know your IP is: ".. math.random(1,200).."."..math.random(1,200)..".".. ".1.1.", "All")
wait(3)
speaker:SayMessage("I know your local time is ".. hour.. ":".. min, "All")
end)

i removed the other errors in your code

5 comments

0

Hello, tranks for your help but it didn't work.

0

Now no error appears but it only works up to this line speaker: SayMessage ("I am coming to your house", "All")

0

Doritos... Am like doritos

0

i removed other mistakes in your code

0

thank you very much!

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