i made 2 scripts connected to each other using RemoteEvent to give player a uniform if he answer with "Yes" (Dialog)
But.. its only working if i tested in-studio, and its not working in-game.
the First located in the NPC
local debounce = true local UniEvent = game.ReplicatedStorage:WaitForChild("UniformGiveEvent") script.Parent.DialogChoiceSelected:connect(function(player, choice) if choice == script.Parent.Yes then if debounce then debounce = false UniEvent:FireServer() end end end)
and the Second located in the ServerScriptService
local Event = Instance.new("RemoteEvent") Event.Parent = game.ReplicatedStorage Event.Name = "UniformGiveEvent" local Shirt = "rbxassetid://000000000" -- Random code local Pants = "rbxassetid://000000000" -- Random code function GiveUni(plr) local character = plr.Character local shirt = character.Shirt local pants = character.Pants shirt.ShirtTemplate = Shirt pants.PantsTemplate = Pants end Event.OnServerEvent:Connect(GiveUni)
Please Help Me!
ServerStorage
service. Use local servers to test scripts instead.Anyway, since DialogChoiceSelected
is server-sided, you don't need any RemoteEvent
s. The uniform giving script can also error if a player doesn't have a shirt or pants.
local Shirt = "rbxassetid://000000000" -- Random code local Pants = "rbxassetid://000000000" -- Random code local debounce = true local function GiveUni(plr, choice) if choice == script.Parent.Yes then if debounce then debounce = false local character = plr.Character local shirt = character:FindFirstChild("Shirt") or Instance.new("Shirt") local pants = character:FindFirstChild("Pants") or Instance.new("Pants") shirt.ShirtTemplate = Shirt pants.PantsTemplate = Pants shirt.Parent = character pants.Parent = character end end end script.Parent.DialogChoiceSelected:Connect(GiveUni)