Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script that gives a tool when a dialog choice is picked?[CLOSED]

So this script works in studio, but it doesn't work in-game. It doesn't even print. The point of this script is to tell another server script to give a tool when a dialog choice is selected.

--This is a script, not a local script
--The game is FilteringEnabled
local RepService = game:GetService("ReplicatedStorage") 
local GiveCrateEvent = RepService:WaitForChild("Events"):WaitForChild("GiveCrate")

script.Parent.DialogChoiceSelected:connect(function(player, choice)
	if (choice == script.Parent.Stock.ASand.AYes) then 
		print(player.Name.." asked for a Sand Crate")
		GiveCrateEvent:Fire(player,"ASandCrate")
	end
end)

The other script:

--Also a script
--Located in SSS
local RepStorage = game:GetService("ReplicatedStorage")
local GiveCrateEvent = RepStorage:WaitForChild("Events"):WaitForChild("GiveCrate")
local ServerStorage = game:GetService("ServerStorage")
local CrateStorage = ServerStorage.Crates

GiveCrateEvent.Event:connect(function(player, crate)
	local ChosenCrate = CrateStorage:FindFirstChild(crate)
	local CrateClone = ChosenCrate:clone()
	CrateClone.Parent = player.Backpack
	print("Gave "..player.Name .." a ".. crate)
end)

I have absolutely no idea why this won't even print in-game. Any help would be appreciated. Thanks.

I'm going to make my own set of gui dialogs instead. Thanks for those who tryed to help me solve this problem. :)

4 comments

0

Is it a local script or a script. Also where is it placed in the game? Under workspace, lighting, replicatedstorage?

0

This script is in the workspace under the NPC's head. This is a server script.

0

Is Experimental Mode off for you (Is Filtering Enabled On? ), or is it Experimental Mode on for you(Is Filtering Enabled Off?)?

0

Filtering Enabled is on/Experimental mode is off.

3 answers

Try switching to a Local Script.

1 comment

0

This didn't work in-game or in studio, and yes I modified the bindable event to a remote event and changed the scripts accordingly. It still didn't work in studio or game.

--This is a script, not a local script
--The game is FilteringEnabled

--A choice can't be equal to DialogChoice box, a choice must equal to the DialogChoice box's name!



local RepService = game:GetService("ReplicatedStorage") 
local GiveCrateEvent = RepService:WaitForChild("Events"):WaitForChild("GiveCrate")

script.Parent.DialogChoiceSelected:Connect(function(player, choice)
    if choice.Name == script.Parent.Stock.ASand.AYes.Name then  
        print(player.Name.." asked for a Sand Crate")
        GiveCrateEvent:Fire(player,"ASandCrate")
    end
end)

4 comments

0

Adding .Name to the script caused it not to work in-game or in-studio. Thanks for trying

0

Edited, try now.

0

@Crazycat4360 If that don't work then please show me your script and dialogue boxes are set up.

RemoteEvents and RemoteFunctions can only send data from server to client or client to server, not server to server or client to client. A fix would be to use BindableFunctions as that is what it looks like what you are trying to accomplish. I don't see any errors in your script though, so all you need to do is change the remote function to a bindable function with no changes to your script.

Hope this helps!

7 comments

0

@hiimgoodpack I changed back to a bindable event from my answer above a while ago. The wiki said that Remotes can only send server-to-server and c-to-c like you said. However I don't see why I should use a bindable function over a bindable event, because I don't need anything returned to the original script from the script giving the crate

0

What you were doing was using a remote function, so I assumed you were returning something.

0

I though :Fire and .Event were for Bindable Events, and :Invoke and .OnInvoke were for Bindable Functions? I used :Fire and .Event in my scripts.

0

How would you have thought I was using a Bindable Function?

0

Remote Function*

0

You were using :InvokeServer or whatever before you updated question.

0

I never have used a Remote or bindable function once in this script

This discussion is preserved as it was. New answers, comments, and votes are closed.