Don’t know what’s the error, but I am not to be able to find a solution for it
script.Parent.DialogChoiceSelected:Connect(function(plr, msg)
print("fired")
if msg == "I found Key" then
local inv = plr.Backpack
local chr = plr.Character
if inv:FindFirstChild("Key_1") or chr:FindFirstChild("Key_1") then
game.ReplicatedStorage["Key Events"].key1:FireClient(plr)
else
script.Parent.DialogChoice.DialogChoice.ResponseDialog = "You don't have key :/"
end
end
end)
This is a script parented under the Dialog. Nothing is printing, no errors either.
I want to do something when player active the dialog
Not sure what did not work for you, but here’s how it should be set up:
Script:
local rplfirst = game:GetService("ReplicatedFirst")
local event = rplfirst:FindFirstChild() -- What's the name of your event?
script.Parent.DialogChoiceSelected:Connect(function(plr, msg)
print("fired")
if msg == "I found Key" then
event:FireServer()
end
end)
LocalScript:
local rplfirst = game:GetService("ReplicatedFirst")
local event = rplfirst:FindFirstChild() -- Again, what is the name of your event?
event.OnServerEvent:Connect(function(plr) -- Player is the first parameter automatically.
local inv = plr.Backpack
local chr = plr.Character
if inv:FindFirstChild("Key_1") or chr:FindFirstChild("Key_1") then
game.ReplicatedStorage["Key Events"].key1:FireClient(plr)
else
script.Parent.DialogChoice.DialogChoice.ResponseDialog = "You don't have key :/"
end
end)
This event is client-side only and will not fire on the server. It should be connected to in either a LocalScript or a ModuleScript required by a LocalScript .
You should consult the official documentation before creating a thread.