How to make a writtable paper

Hey !
I’m trying to make a writtable paper system. When the player click on the paper model, it’ll open a gui, the player can write whatever he wants. And when he leaves the gui, it saves the text for everyone, so they can read it, here is the script :
Local script :

script.Parent.MouseButton1Click:Connect(function()
	local text = script.Parent.Parent.TextBox.Text
	game.Workspace.Paper.RemoteEvent:FireServer(text)
	script.Parent.Parent.Parent:Destroy() 
end)

Script :

local textBoxInput = script.Parent.WrittablePaper.Frame.TextBox

function onClick(click)
	for i,v in pairs (script.Parent:GetChildren()) do
		if v.ClassName == "ScreenGui" then
			local c = v:Clone()
			c.Parent = click.PlayerGui
		end
	end
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

script.Parent.Parent.RemoteEvent.OnServerEvent:Connect(function(text)
	script.Parent.Parent.Content.Value = text
	print(text)
end)

script.Parent.Parent.Content.Changed:Connect(function ()
	textBoxInput = script.Parent.Parent.Content.Value
end)

1 Like

You can use UserInputService to see when mouse is pressed down using IsMouseButtonPressed, then you can draw on the paper wherever the mouse goes by using Mouse.X and Mouse.Y.

1 Like

I tried something like the quoted text before, when doing something, and it didn’t work.

Try something like this example:
local text = game.Players.LocalPlayer:WaitForChild("PlayerGui").ScreenGui.WrittablePaper.Frame.TextBox.Text

Looking at the script, I think he meant type.

It doesn’t work, but it prints me the following error :

Oh in that case you make a textbox and let the player type in it, and when they are done you send the text to the server. Remember to use TextFilter though or the game will be moderated.

I already thought about that, but he didn’t ask anything about it.

Then I’m not sure what the problem is.

When the player close the gui, instea dof saving what he wrote, it’ll reset the content of the textbox (to open gui, it clones the gu present inside the model into PlayerGui)

Just change the ‘text’ variable to wherever the TextBox is, in your LocalPlayer, not script.Parent.Parent.Example.TextBox

Ye, but to put it inside the stringvalue for everyone, I need to use RemoteEvent

No, no. I meant in the LocalScript. lol – I noticed because it said ‘Server’ not 'Client;

I think what you are trying to say is that when the player unfocuses from the Textbox it resets the text. To prevent that you simply untick ClearTextOnFocus property of the Textbox.

No, you didn’t got it lmao.
When the player CLOSE the gui, it will save what he wrote, not when he clicks agai

So where does the problem lie? you don’t want it to save the text? I am very confused right now.

The problem is that the text doesn’t save when he closes and reopens the GUI

What is script.Parent.Parent.Parent equal to? (instance/classname)

I think your destroying the gui, and that is the problem.

Well are you deleting the Textbox? If so why? do you need to? If you really need to (I don’t know why you would) you can save the text in a variable or something.

I’m destroying the GUI so it doesn’t open a copy of it, It is wanted. So when we destroy it, we simply save what he wrote in the default model of the game, the one that is cloned when we click on the part
– And I’m trying to save the script into a StringValue then set the text of the default TextBox into what is in the String

Isn’t the player parameter supposed to be there, and be first?

Or not the problem?