Problems finding a certain model in workspace

Hi! i have a problem and i can’t find a model with a certain name in workspace. my script works like this: the client makes a clone of a model that is in replicatedstorage, once it clones it, it assigns a random name using HttpService, then it makes a fireserver with the name generated by the HttpService, after making the OnServerEvent, it saves the variable of the name received and it searches for it in workspace. but it doesn’t work and i don’t know why.

LOCAL SCRIPT

local npc = game.ReplicatedStorage.NegotiationSystem:WaitForChild('Rig'
local addition = npc:Clone()
local uniqueId = game:GetService("HttpService"):GenerateGUID(false)
	addition.Parent = workspace
	addition.Name = uniqueId
 print("The client sent: "..uniqueId)
	ReplicatedStorage.NegotiationSystem.RandomizeModel:FireServer(uniqueId)

SERVER SCRIPT

game:GetService("ReplicatedStorage").NegotiationSystem.RandomizeModel.OnServerEvent:Connect(function(player, uniqueId)
     print("The server received: "..uniqueId)
	
	local NPC = workspace:FindFirstChild(uniqueId)
	
	if NPC then
		print("model found", NPC)
	else
		print("model not found.")
		end

CONSOLE:

 19:55:25.689  The client sent: 1258022b-5eec-4538-a16d-56497cec94f3  -  Cliente
  19:55:25.704  The server received: 1258022b-5eec-4538-a16d-56497cec94f3  -  Servidor
  19:55:25.704  model not found.  -  Servidor

image

1 Like

If you create an instance on the client, it isn’t replicated to the server (or other clients).

1 Like

then should I do the :clone on the server?

1 Like

Depends what exactly you’re trying to do. Looks like you’re making some sort of NPC? What does the client use this NPC for? Why does the server need to know about it? Should the NPC be replicated to other clients?

actually the npc only serves to activate a proximityprompt and activate a negotiation system that I already have done, after finishing and reaching an agreement, I wanted to make a fire with a bindable event for the npc to do some dances. The server script is just to randomize the npc’s outfit but in order to do that I need to know which npc was cloned so I can assign that specific npc certain clothes.

Any reason it wouldn’t be possible to randomize the appearance of the NPC and trigger the dance animation on the client? You can listen for the Triggered event of a ProximityPrompt on the client by the way, so depending on what the “negotiation” logic entails, you might be able to do all the work on the client until sending the final result to the server.

yes but i’m afraid of exploiters that can access my localscripts and copy them, that’s why i want to add some serverscript too. i’ve heard that it’s very common to access and uncopylock systems like this.

What happens during “negotiation”? Is the final result something like an accept/decline, or multiple choice (or multiple of these)?

it’s just accept or reject. but i’m making that if he rejects just leave but if he accepts, then do the dance and then leave. but to know which npc must dance and which npc must leave i must send it in event, as you can’t send instances in events, i thought to generate a random name and send it, once you receive it there if you search for it in workspace and easily you should be able to find the npc that way, but it didn’t work. By the way the whole part of my negotiation is localscripts and the part of placing random clothes on the npcs and also make a npc queue, that is handled with a server script.

Unless the NPCs should be visible to all clients, that logic sounds like it should all be handled on the client. Theres really no reason to worry about exploiters in a case like this, as they could just as easily (if not even more easily) access RemoteEvent and RemoteFunction and pass whatever values they want.

1 Like

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