Can Touched Function Be Used in Client-Parts?

Hi! I have a part that appears only for the client, but it requires a touched function to work and progress through the code. Basically, touching the first part, prompts you to accept a job, and spawns a new part, for the client only. This new part must be touched to work, but it is not working when a new server is involved. How can I work around this to make touched functions work in client parts?

Thanks!

Are you calling .Touched:Connect() in the new part or in the script that spawns the new part?

In the new part.

Can we see the source code so we know exactly what you’re trying to do?
Is your place FE?

I’m also sure you’re going to need to use a RemoteFunction for this.

Yes, I am using FE, I’ll show you how it works. I use all RemoteEvents. Warning: Might be a long post.

First, from a UI, an “Accept” button is clicked, spawning the part.

script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Parent = UI

First, the function is called and fired.

job.Value = "Pizza Delivery"
taskOnePart.Parent = game.Workspace
end)

From there, I move the part into workspace, keep in mind this is from a local script.

The code of the first part:

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
taskOne:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
end
end)

Finally, here is the linked local script.

pizzaTaskOne.OnClientEvent:Connect(function()
game.Workspace.pizzaTaskOnePart.Parent = pizzaParts
pizzaTaskTwoPart.Parent = game.Workspace
end)

This is a server script in the part. When this happens, nothing happens. No error, but no parts change. I’m wondering if I need to externally call .Touched? Thanks for your help!

1 Like

EDIT: just found out you cant fire a remote through a server script, haha, woops.

I’m also very eagered to know how to accomplish this. I’ve tried a lot of things but nothing has worked for me either, so I can’t help you. Instead, I’ll be watching this post unless you have a solution yourself.

I have a solution, I can help you. Basically, I called it through a server script, using waitforchild for the part to be in workspace. Once it was in, the server handled all touched events. I reccomend a server function handler.

1 Like

I see. I didn’t quite see this as useful because the players in my game will be able to insert the part multiple times, so WaitForChild() will only work once, thus can’t be used with this.

However, I think I can figure a workaround.