hello!!!
So, I’ve been attempting to make a dialogue system. I tried giving it functionality between both the client and the server. But that’s where things got a little weird.
So here’s the client sending a RemoteEvent to the server with all the dialogue parameters:
dialogue:FireServer(3, "Good morning, Bikini Bottom! Another beautiful day to work...", CFrame.new(264.358093, 30.3439865, 241.909363, -0.630638838, -0.0015594518, -0.776074946, 0, 0.999997973, -0.00200940482, 0.776076496, -0.00126720872, -0.630637586))
dialUI:GetPropertyChangedSignal("Enabled"):Wait()
dialogue:FireServer(3, "Objective: Head to the Krusty Krab!", CFrame.new(271.419769, 12.3791313, -228.366959, -0.999915302, 0.0014154258, 0.012938994, 0, 0.994069815, -0.108743548, -0.013016182, -0.108734339, -0.993985593))
dialUI:GetPropertyChangedSignal("Enabled"):Wait()
Then, the server receives the Event. The server then transfers parameters to the client, where the dialogue is displayed.
Server transfer:
local dial = game.ReplicatedStorage:WaitForChild("DialogueClient")
dial.OnServerEvent:Connect(function(player, duration, text, cframe)
-- CFrame not required for execution of the dialogue
if cframe ~= nil then
print("SERVER:", player, duration, text, cframe)
dial:FireClient(player, duration, text, cframe)
else
dial:FireClient(player, duration, text)
end
end)
Client Handler:
local event = game.ReplicatedStorage:WaitForChild("DialogueClient" )
local deb = false
event.OnClientEvent:Connect(function(duration, text, cframe)
print(duration, text, cframe)
if deb == false then
deb = true
local gui = script.Parent:WaitForChild("Dialogue")
local frame = gui:WaitForChild("Frame")
local dialogue = frame:WaitForChild("TextLabel")
-- Change camera cframe if provided
if cframe ~= nil then
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = cframe
end
gui.Enabled = true
dialogue.Text = ""
print(duration, text, cframe)
for i = 1, #text do
script.Parent:WaitForChild("Speak"):Play()
dialogue.Text = string.sub(text, 1, i)
wait(0.04)
end
wait(duration)
print(text)
gui.Enabled = false
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
event:FireServer()
deb = false
end
end)
Now, this is where it gets wacky. The first line of dialogue sent to the server works fine.
dialogue:FireServer(3, "Good morning, Bikini Bottom! Another beautiful day to work...", CFrame.new(264.358093, 30.3439865, 241.909363, -0.630638838, -0.0015594518, -0.776074946, 0, 0.999997973, -0.00200940482, 0.776076496, -0.00126720872, -0.630637586)
But, the second line of the dialogue set makes it past the client > server. But the client handler returns all dialogue parameters as nil
16:43:07.401 nil nil nil - Client
This was outputted using this bit of code in the handler:
print(duration, text, frame)
any help is appreciated