I have a GUI with a textbox and a button. When the button is pressed, the text from the textbox is read and a remote event is fired.
Upon this activation, another script is supposed to find a model with the name consisting of the input from the textbox and, if this model exists, clone it into Workspace in front of the player.
If the model does not exist, the script should check if the string isn’t contained in a table defined beforehand, and send a Discord message through a webhook.
However, when I type in a string and click the button, the script does not do anything, no matter if the model exists or not.
local rejected = {
"thing","other stuff"
}
local repstorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:wait()
local character = player.Character or player.CharacterAdded:wait()
local humroot = character:WaitForChild("HumanoidRootPart")
local RE = game.ReplicatedStorage.RemoteEvent
local hook = "https://webhook.lewisakura.moe/api/webhooks/1259110789449650226/C7IYPeH1vnOSZUTPizKk7aGiWbOyjq32CqlcZyhaWmQJtsK9HCKrAXPUTRFu_0JHCWHW"
local http = game:GetService("HttpService")
RE.OnServerEvent:Connect(function(plr, textInput)
if repstorage.Stuff:FindFirstChild(textInput) == true then
local model = repstorage.Stuff:FindFirstChild(textInput)
local modelclone = model:Clone()
modelclone.Parent = workspace
modelclone:SetPrimaryPartCFrame(humroot.CFrame)
modelclone:TranslateBy(Vector3.new(5, 0, 5))
else
if table.find(rejected,textInput) == false then
local data = {
['embeds'] = {{
['title'] = textInput,
['description'] = "A new submission has been made: **"..textInput.."**",
['color'] = tonumber(0xF57D34)
}
}
}
local finalData = http:JSONEncode(data)
http:PostAsync(hook,finalData)
end
end
end)
Any ideas?