Why is this remote event not working?

I’m attempting to create an NPC talking system which disables the player’s movement and passes dialogue from a server script parented to a proximityprompt. These variables contain strings that I want to use on the client side script to print dialogue, also parented to a proximityprompt. I’m using a remote event to send the variables

The issue is that when I’m firing the event to the client from the server script, the OnClientEvent event doesn’t do as it was told.

Server script:

local prompt = script.Parent
local event = game:GetService("ReplicatedStorage"):WaitForChild("NPCTalk")

local d1 = "dialogue1"
local d2 = "dialogue2"
local d3 = "dialogue3"

prompt.Triggered:Connect(function(plr)
	event:FireClient(plr, d1, d2, d3)
end)

Client script:

local players = game:GetService("Players")
local player = players.LocalPlayer
local event = game.ReplicatedStorage:WaitForChild("NPCTalk")

event.OnClientEvent:Connect(function(d1, d2, d3)
	player.Character.Humanoid.WalkSpeed = 0
	player.Character.Humanoid.JumpPower = 0
	print(d1, d2, d3)
end)

What seems to be the problem here?

Elaborate please on what it does wrong, does it print the d1, d2 and d3?

Yea, the thing it isn’t doing is printing those.

Where is the local and server script located? I recreated your scenario in studio and it works just fine.

They are both stored in the proximity prompt being triggered.

I think I know the problem, local scripts don’t run in workspace, you have to place them on the client, so any of the following:

  • StarterGui

  • StarterCharacterScripts

  • StarterPlayerScripts

Wow, thanks a lot. Can’t believe I made another silly mistake to not remember that client scripts wouldn’t run where I placed them.

1 Like

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