Server Event fire on touch

I have a remote event in Replicated storage that I need fired, and used in another script. However, the event won’t fire, idk why. can someone help?

Here are the two scripts

script.Parent.Touched:Connect(function(Hit)
	if Hit and Hit.Parent:FindFirstChild("Humanoid") then
		game.ReplicatedStorage.SpawnChick:FireServer()
	end
end)
local SpawnName = game.ReplicatedStorage:FindFirstChild("ChickenL4")
local S = script.Parent.Chicken
local Spaw = game.ReplicatedStorage.SpawnChick
local chicken = game.ReplicatedStorage.ChickenL4

Spaw.OnServerEvent:Connect(function()
	chicken:clone()
	chicken.Parent = game.Workspace
	chicken.Position = script.Parent.Position
	S:Play()

	print("Spawned!")
end)
1 Like

thats crazy bro but like what are you asking for

I edited it, sorry I forgor :skull: The event won’t fire

What are you trying to do?

Text

Assuming this part is in the workspace, and since you are using FireClient, Im guessing this script is inside of a LocalScript. LocalScripts cant run in the workspace, they can only work on the players Character (i forgot the name but things that :SetNetworkOwnership() is on), PlayerGui, StarterPlayer/Character, Backpack, etc. They cant run in workspace which is why your event isnt firing

1 Like

@joshuaThe5th
You dont need a RemoteEvent for this, you can just use a standard Script:


To point out One of your Errors:

You Aren’t specifying what the Chicken Clone is, you are setting the real chicken object to the workspace instead of the clone


Possible fix:

local SpawnName = game.ReplicatedStorage:FindFirstChild("ChickenL4")
local S = script.Parent.Chicken
local Spaw = game.ReplicatedStorage.SpawnChick
local chicken = game.ReplicatedStorage.ChickenL4

local function SpawnChicken()
local C = chicken:clone()
	C.Parent = workspace
	C.Position = script.Parent.Position
	S:Play()

	print("Spawned!")
end



script.Parent.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
		SpawnChicken()
	end
end)

It appears that you are using a RemoteEvent to connect 2 Server scripts. I would recommend just placing the .Touched function inside of the other script that spawns chickens. The alternative would just be to use a Bindable Event to connect the 2 scripts.

This doesn’t work, not a output

Try this:

local SpawnChick = game:GetService("ReplicatedStorage"):WaitForChild("SpawnChick")

script.Parent.Touched:Connect(function(Hit)
	if Hit and Hit.Parent:FindFirstChild("Humanoid") then
		SpawnChick:FireServer()
	end
end)
--local SpawnName = game.ReplicatedStorage:FindFirstChild("ChickenL4") ???
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local S = script.Parent.Chicken
local Spaw = ReplicatedStorage:WaitForChild("SpawnChick")
local chicken = ReplicatedStorage:WaitForChild("ChickenL4")

Spaw.OnServerEvent:Connect(function()
	chicken:clone()
	chicken.Parent = game.Workspace
	chicken.Position = script.Parent.Position
	S:Play()

	print("Spawned!")
end)

This was on old part that is no longer used, I already removed it

1 Like

This doesn’t work either, no output

1 Like

Can you show me the output?