Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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. :)

0
Is it a local script or a script. Also where is it placed in the game? Under workspace, lighting, replicatedstorage? GottaHaveAFunTime 218 — 6y
0
This script is in the workspace under the NPC's head. This is a server script. 6xxnoobxx6 -5 — 6y
0
Is Experimental Mode off for you (Is Filtering Enabled On? ), or is it Experimental Mode on for you(Is Filtering Enabled Off?)? JoeRaptor 72 — 6y
0
Filtering Enabled is on/Experimental mode is off. 6xxnoobxx6 -5 — 6y

3 answers

Log in to vote
0
Answered by
Kulh 125
6 years ago

Try switching to a Local Script.

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. 6xxnoobxx6 -5 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
--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)

0
Adding .Name to the script caused it not to work in-game or in-studio. Thanks for trying 6xxnoobxx6 -5 — 6y
0
Edited, try now. JoeRaptor 72 — 6y
0
@Crazycat4360 If that don't work then please show me your script and dialogue boxes are set up. JoeRaptor 72 — 6y
Log in to vote
0
Answered by 6 years ago

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!

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 6xxnoobxx6 -5 — 6y
0
What you were doing was using a remote function, so I assumed you were returning something. hiimgoodpack 2009 — 6y
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. 6xxnoobxx6 -5 — 6y
0
How would you have thought I was using a Bindable Function? 6xxnoobxx6 -5 — 6y
View all comments (3 more)
0
Remote Function* 6xxnoobxx6 -5 — 6y
0
You were using :InvokeServer or whatever before you updated question. hiimgoodpack 2009 — 6y
0
I never have used a Remote or bindable function once in this script 6xxnoobxx6 -5 — 6y

Answer this question