Attempt to concatenate string with Instance?

  1. What do you want to achieve? Keep it simple and clear!

I am making a projector that uses an event and fires it when the textbox losses focus from the player using it. The textbox takes the “ImageID” and puts this ID into the surfaceGUI of the projector screen.

  1. What is the issue? Include screenshots / videos if possible!

The issue is that I am getting this error:

Workspace.ProjectorScreen.EnterImage:2: attempt to concatenate string with Instance – Line 2 of my server script.

Server script (OnServerEvent)

game.ReplicatedStorage.ProjectObject.OnServerEvent:Connect(function(text)
	script.Parent.ProjectedObject.Image.Image = "rbxassetid://"..text
	print("Image successfully displayed")
end)

Local script (inside textbox)

script.Parent.FocusLost:Connect(
	function(enterPressed)
		if enterPressed then
			local text = script.Parent.Text
			game.ReplicatedStorage.ProjectObject:FireServer(text)
			print("New image displaying")
		end
	end
)

What am I doing wrong? I never experienced this type of error.

There is a RemoteEvent inside of ReplicatedStorage.

OnServerEvent has the Player Instance as the first parameter, not your tuple arguments (Or text)

Try this:

--Server
game.ReplicatedStorage.ProjectObject.OnServerEvent:Connect(function(Player, text)
	script.Parent.ProjectedObject.Image.Image = "rbxassetid://"..text
	print("Image successfully displayed")
end)
4 Likes

It works! Thank you! Also, should I test this feature in studio or real game because when I am testing in studio, it shows that I cannot display the image:

Image https://assetdelivery.roblox.com/v1/asset?id=68437732 failed to load. Error 403: Asset type does not match requested type

Nevermind, it must be made by Roblox or the group. Solved it myself. Thanks though for the other problem!