So, the script is for the dialog and the collectable. So, I have it so the item you give to the person is destroyed and gives you a collectable. I'm not a good scripter so I may make some obvious mistakes, but I just need a few pointers.~~~~~~~~~~~~~~~~~
game.Players.LocalPlayer.Backpack.Baby:Destroy()
local identifier = "gemtesterbester"
local stat = "Gems"
local description = "You found iDarricks Baby. Now he ate baby. You monster."
local respawn = false
local debounce = false
if not debounce then
debounce = true
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player then
if player:findFirstChild("OneTimeItems") and player:findFirstChild("leaderstats") and not player.PlayerGui:findFirstChild("ItemGet") then
if not player.OneTimeItems:findFirstChild(identifier) then
--create an identifier (accoutrements have cool icons)
local newidentifier = Instance.new("Accoutrement",player.OneTimeItems)
newidentifier.Name = identifier
--update stats
local stats = player.leaderstats:findFirstChild(stat)
if stats then
stats.Value = stats.Value + 1
else
print(stat.." not found in leaderstats")
end
--show description
local newgui = workspace.MainGameScript.ItemGet:clone()
newgui.Parent = player.PlayerGui
newgui.Frame.Description.Text = description
--thread separately so it doesn't hold up the rest of the script
Spawn(function()
newgui.Frame:TweenPosition(UDim2.new(0.5, -150, 0.5, -60), "Out", "Elastic", 2)
wait(6)
newgui.Frame:TweenPosition(UDim2.new(0.5, -150, 0, -300), "Out", "Elastic", 2)
wait(1)
if player:findFirstChild("Checkpoint") then
--reset checkpoint
player.Checkpoint.Value = Vector3.new()
end
if respawn then
if player:findFirstChild("Checkpoint") then
--reset checkpoint
player.Checkpoint.Value = Vector3.new()
end
player:LoadCharacter()
else
newgui:Destroy()
end
end)
else
--let the player know they already have this item
local newgui = workspace.MainGameScript.ItemGet:clone()
newgui.Parent = player.PlayerGui
newgui.Frame.Description.Text = "You already have this item!"
--thread separately so it doesn't hold up the rest of the script
Spawn(function()
newgui.Frame:TweenPosition(UDim2.new(0.5, -150, 0.5, -60), "Out", "Elastic", 2)
wait(6)
newgui.Frame:TweenPosition(UDim2.new(0.5, -150, 0, -300), "Out", "Elastic", 2)
wait(1)
if respawn then
if player:findFirstChild("Checkpoint") then
--reset checkpoint
player.Checkpoint.Value = Vector3.new()
end
player:LoadCharacter()
else
newgui:Destroy()
end
end)
end
end
end
debounce = false
end
end)

2 comments
(the destroy baby function isn't identifying as a script for some reason. :C
Please fix the Lua formatting, it seems some of the code isn't included in the tildes.