Hello, I am new at programming and would like some help regarding something I wanted to create.
I want to create a customizable note system.
Upon clicking on the sheet of paper on the table, I want a GUI to pop up where it shows what I write. After I finish, there is a button to take a letter, it would give me a cloned tool of a letter with my text on it and I am able to put it on a wall with raycast. The remote event needs to be fired so other players can see the letter on the wall.
I am wondering how would I be able to do this with a script.
I put this LocalScript on a Part in workspace. This Part is the letter, when clicking on it, it’s supposed to open the GUI so I can write. But nothing is happening and it doesn’t even print anything. I have a ClickDetector in there as well, the mouse changes the shape as it’s clickable, but as I said, the script won’t run for some reason.
-- Reference to the GUI elements
local gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")
local textBox = gui.TextBox
local submitButton = gui.TextBox.TextButton
-- Function to handle the submit button click
local function submitButtonClick()
local noteContent = textBox.Text
-- Clone the note as a tool and add it to the player's backpack
local noteTool = game.ReplicatedStorage.NoteTool:Clone()
print("Cloned Tool.")
noteTool.Note.SurfaceGui.Text.Text = noteContent
print("Put written text on tool.")
noteTool.Parent = game.Players.LocalPlayer.Backpack
print("Put in backpack.")
-- Close the GUI
gui.Enabled = false
print("Gui closed.")
end
-- Connect the submit button click event
submitButton.MouseButton1Click:Connect(submitButtonClick)
print("Clicked submit.")
-- Function to handle object click
local function objectClick()
-- Open the GUI
gui.Enabled = true
print("Gui enabled")
end
-- Connect the object click event
script.Parent.ClickDetector.MouseClick:Connect(submitButtonClick)
print("ClickDetector activated.")
LocalScript’s dont work unless parented to the client. You will have to fire a RemoteEvent from a server script when player clicks on it, then fire the event from a player when they submit (that localscript has to be inside the gui). Alternatively you can do all of that on the client (by having the localscript listening to the clickdetector parented to the client) if you dont care about other players seeing you having the note. When making it so other players can see the note you will have to filter the text with:
I just spent a few minutes working on a quick system for making these notes and getting a tool created for the player that stores the title and message in it. I haven’t worked on the placing system. I hope this somewhat helps! Have a wonderful day!