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)
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.
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.
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)
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.
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