Hello everyone, my name is spideyalvaro
So today I was testing something reall unusual. first of all I wanted a script that destroy a model on a conversation. I mean, for example you have an NPC and on that NPC you have a dialog with some dialog choices, so I wanted that on one of those dialog choices(on the last one) the model is destroyed after the NPC talks the last dialog choice. I dont know if this is posible, but I tryed all the posible things I know but non of this worked
Do you know how to make it posible?
Thanks for spending your time trying to do this thing
Spideyalvaro
It’s actually very easy and involves little lua scripting
Dialog=--whereisdialog
npc=--whereisnpc
Dialog.DialogChoiceSelected:connect(function(p,c)
if c.Name == "last" then
npc:Destroy()
end
end)
dont forget to define the variables
Edit:
Added the variables
An I have to name the lat dialog choice as "last"
right?
Yes! Exactly although theres ages i dont use the default dialogue from roblox engine, so I’d suggest you test
But I want to meake it on the client so a local script will work? and where I should place the local script, on the npc or on the workspace?
I think a Local Script would work; you could put the script anywhere, but I suggest putting it inside the NPC. If you put the script inside the NPC, change ‘npc=–whereisnpc’ to ‘npc = script.Parent’.
yeah but it doesnt work. I have 1 dialog and 2 dialogchoice
I dont know if i have to put this:
`
local Dialog = workspace.NPC.Head.Dialog
this
local Dialog = workspace.NPC.Head.Dialog.DialogChoice
or this
local Dialog = workspace.NPC.Head.Dialog.DialogChoice.last
`
If he went the local script route, he can’t put it anywhere. Local scripts only work in a place that is replicated to the client. Such as startergui, starterplayer, or starterpack.
You have to type this:
local Dialog = NPC.Head.Dialog.last
but there is a dialogchoice inside the dialog, and inside the dialog choice there is the “last”
so a local script inside the NPC woill not work right?
Okay, so, move the LocalScript to StarterPack and type or paste this script on the LocalScript:
Make sure to change ‘NPC-Name-Here’ to the name of your NPC on Workspace.
NPC = workspace:WaitForChild("NPC-Name-Here")
Dialog = NPC.Head.Dialog.DialogChoice
Dialog.DialogChoiceSelected:Connect(function(p,c)
if c.Name == "last" then
NPC:Destroy()
end
end)
I’ve change the name of the NPC on the cript, and placed the local script on the starter pack and it doesnt work
Well, then I don’t know how to make it work only for client. I’m sorry. Try searching on YouTube on how to make something only work for client.