Server to client event will not fire

Made a simple server to client script so that when a player does a certain quest a wall will be client sided to be open/cannot collide but the remote event never fires.

server

local wall = game.Workspace.QuestWalldetector
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local PlayerData = require(ServerScriptService.PlayerData.Manager)
local Event = ReplicatedStorage.CheckIfQuest

wall.Touched:Connect(function(Hit)
	local Humanoid = Hit.Parent:WaitForChild("Humanoid")
	
	if Humanoid then
		local player = game.Players:GetPlayerFromCharacter(Humanoid.Parent)
		local profile = PlayerData.Profiles[player]
		
		if not profile then return end
		
		local QuestReceived = profile.Data.QuestReceived
		
		if QuestReceived == true then 
			--it does make it here, I checked with print()
			Event:FireClient(player)
			
		end
	end
end)

client

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.CheckIfQuest

local wall = script.Parent

Event.OnClientEvent:Connect(function()
	--if i print() something here, it does not print.
	wall.CanCollide = false
	
end)

Where did you put the localscript?

Inside the wall that disappears

also try printing after every if statement to see which if statement is not functioning

The localscript won’t run inside the wall. You can put it inside StarterPlayerScripts

local scripts cant access the workspace

I will try accessing it by making a parameter when i fire the client ig

Screenshot 2023-11-29 051652

I fixed it! I put the local script in player scripts and referenced the wall with parameters from the server script!

No, it can access the workspace, you’ve misunderstood.

1 Like

i just found out but thanks for telling me!

Ex:’

You did :WaitForChild(“Humanoid”) then did if Humanoid. I assume you want :FindFirstChildWhichIsA(“Humanoid”). In fact you don’t need to Humanoid at all since you’re interested in

local player = game.Players:GetPlayerFromCharacter(Hit.Parent) 

Then do if player instead.  

Print out profile and QuestReceived as well.

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