I am making a dialog item giver so if someone chooses an item they get the item but when I finished the scripts and everything it comes up with an error saying.
Attempt to index nil with Parent.
I put the localscript for the dialog giver in StarterPlayerScripts and I used a serverscript.
LocalScript:
local dialog = workspace.npc.Head.Dialog
local function onSelected(player, choice)
if choice == dialog.IceCream then
local item = game.Lighting.IceCreamCone
game.ReplicatedStorage.BuyItem:FireServer(player, item)
end
end
dialog.DialogChoiceSelected:Connect(onSelected)
Try to preform all checks on the server side! A knowledgeable can currently give themself any tool in the game.
For example, if you had a boombox gamepass I could fire the remote with the boombox as the argument and then I would get the boombox for free. This specifically may not be an issue for you, but as of now any tool in your game can be given to an exploiter through the server.
Instead of checking if choice == dialog.IceCream on the local script, fire the remote event with the argument choice and preform checks on the server