Variable data changes?

What do you want to achieve?
get the choice variable across correctly to a server script without needing to hard code it.

What is the issue?
It replaces the choice variable data with the plr variable data

What solutions have you tried so far?
Changing remote event to remote function and applying the changes necessary.
I can assure that the path to the instances are not wrong.

local script in startercharacterscripts:

local dialog = workspace.AranDev.Head:FindFirstChild("Dialog")
dialog.DialogChoiceSelected:Connect(function(plr, choice)
	print("player name is: ".. plr.Name)
	print("choice name is: ".. choice.Name)
	game.ReplicatedStorage:WaitForChild("GiveGear"):FireServer(plr, choice)
end)

server script in serverscriptservice:

local GivingEvent = game.ReplicatedStorage.GiveGear
GivingEvent.OnServerEvent:Connect(function(plr, choice)
	print("choice name: ".. choice.Name)
	print("plr name:".. plr.Name)
	game.ServerStorage.ToolsF:FindFirstChild(choice.Name):Clone().Parent = plr:WaitForChild("Backpack")
end)

Output:

It might be because the dialogue is only with the client. Correct me if I’m wrong.

What does “choice.Name” print out?

He prints it out here.

If you look at the output line 4 it says “Sword”

to avoid hard coding, i made it so the choice names have the same names as the tools.
In the local script, choice.Name is Sword
In the server script, choice.Name is AranhaDev (my name)
^ should be the same as the local script

As I said check to see if the dialogue is only within the client.

Are you sure that the thing it directs to is correct?

The behaviortype of the dialog is singleplayer (if thats what you mean im not sure if i have another way of detecting if its server or client) making it client only i guess. How would i work around this then?

If the dialogue is only in the client, the server won’t be able to see that object at all (Attempting to send a variable only existing to the client to the server would just return nil because the server doesn’t recognize it). A workaround would be to create the dialogue on the server side, so both can see it.

1 Like

If you’re talking about the path to the tools in serverstorage and stuff, yes I’m sure it is correct

Didn’t take much time to rewrite and it worked, thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.