How to find an object cloned locally?

So I have this script that updates an npcs height with a value change, but i cannot find the npc (which is cloned from replicatedstorage) using a local script, any help, (script im using is server) which is why it cannot find the npc.

If you have something cloned / parented locally, you will not be able to view it on the server.

What you could do is send the server information about the object using remote events/functions, but never trust the client.

4 Likes

How could I do this? Sending information about it over if im going off of value changes in something unrelated to the npc?

Client:

local info = {}
info.Pos = Vector3.new(1,0,0)
event:FireServer(info)

Server:

event.OnServerEvent(plr,info)
print(info.Pos)
end)

Just a simple example of how to do this.

Local

script.Parent.Changed:Connect(function(newValue)

script.Parent.ChangeHeight:FireServer()

end)

server

script.Parent.ChangeHeight.OnServerEvent:Connect(function()
	local h = script.Parent.Value
	game.Workspace:FindFirstChild("HatDummy3").Humanoid.BodyHeightScale.Value = h
	end)

it didnt work tho character30li

Could you provide more details as to what you are trying to do?

Add a parameter to the FireServer in the changed function:

script.Parent.ChangeHeight:FireServer(script.Parent.Value)

Also, is the object with the server side script inside it locally cloned and parented?

The HatDummy3 was cloned locally, which it needs to be.

That means your server script won’t run at all :joy:

But I told you it was cloned locally a while ago…

I didn’t realise your server script was in the actual model itself.

Here’s your solution then.

Its not, the hatdummy3 has no related scripts, etc in it to the scripts and localscripts were discussing right now.

Your server script which you are supposedly receiving the FireServer is locally created, hence it will not run.

Why are you cloning the model on the client-side? Unless it’s specific to your implementation that you need it cloned via the client, just clone it via the server and have the client request such updates to be made by the server instead. Change the mindset, don’t bruteforce it.

1 Like

Its part of my cnharacter creation, and sense many players create characters they dont want to see lrandom dummys everywhere, which is why its local.

Make an actual server side script and setup an OnServerEvent connection and fire it from the client the way I showed you previously.

I have this but something is not working, its timing out also

while true do

script.Parent.Changed:Connect(function(newValue)

wait(0.0001)

local h = script.Parent.Value

game.Workspace:WaitForChild("HatDummy3").Humanoid.BodyHeightScale.Value = h

wait()

end)

end

Why have you put it inside a while loop…?

Im not sure to be completely honest, but what should I do?