I am trying to make a model spawn in when a player types in the model's name into a TextBox and presses an enter button.
The models' name is "apple" and it are stored in ServerStorage. I also have a remote event named JournalEvent in ReplicatedStorage.
I made two scripts, I wanted them to make the apple model appear when the player types "apple" into the TextBox (named "Write") and presses the ImageButton (named "EnterButton")
In StarterGui.JournalGui.JournalFrame I have a local script that says:
local Nouns = {"apple", "tree"} -- disregard tree for this question local RemoteEvent = game.ReplicatedStorage.JournalEvent local frame = script.Parent local gui = frame.Parent local items = frame:GetChildren() local sound1 = script.Parent.Success local sound2 = script.Parent.Book local sound3 = script.Parent.Error local player = game.Players.LocalPlayer script.Parent.EnterButton.MouseButton1Click:Connect(function() for i, item in pairs(items) do if script.Parent.Write.Text == Nouns[1] then sound1:Play() sound2:Play() player.PlayerGui.JournalGui.JournalFrame.Visible = false player.PlayerGui.MiniJournalGui.MiniJournalFrame.Visible = true player.PlayerGui.MiniJournalGui2.MiniJournalFrame2.Visible = false player.PlayerGui.JournalGui.JournalBackFrame.Visible = false player.PlayerGui.JournalGui.FailMessage.Visible = false else script.Parent.Parent.FailMessage.Visible = true sound3:Play() wait(4) script.Parent.Parent.FailMessage.Visible = false item.Activated:Connect(function() local itemName = item.Name game.ReplicatedStorage.JournalEvent:FireServer(itemName, game.Players.LocalPlayer:GetMouse().hit.Position) end) end end end)
In ServerScriptService I have a script that says:
local spawn = game.ReplicatedStorage.JournalEvent spawn.OnServerEvent:Connect(function(plr, itemName, hitPos) local item = game.ServerStorage:FindFirstChild(itemName) if item then local itemClone = item:Clone() itemClone.Parent = game.Workspace itemClone:MoveTo(hitPos) end end)
When I run the game, type "apple" into the textbox, and press enter, the guis all close successfully, but I get an error saying: Activated is not a valid member of TextBox "Players.BunjiBloxxer.PlayerGui.JournalGui.JournalFrame.Write" and the "apple" model doesn't appear.
When I type anything else into the textbox and press enter, nothing happens (which is what I want)
How can I fix this? Thanks