I want create some script. It moves LocalScript to PlayerGui and sets children StringValue to object full name got by GetFullName(). Then I'am trying to get object with link from StringValue using FindFirstChild it not working. Why? How to get object by it link. Or you can advice me better way to realize me idea?

Server script:

seat = script.Parent.Seat

seat.Touched:connect(function()
	repeat wait(0.1) until seat.Occupant ~= nil
	script.OperatorGui:Clone().Parent = game.Players:FindFirstChild(seat.Occupant.Parent.Name).PlayerGui
	game.Players:FindFirstChild(seat.Occupant.Parent.Name).PlayerGui.OperatorGui.Frame.LocalScript.seat.Value = script.Parent.Seat:GetFullName()
end)

Here is LocalScript:

repeat wait() until script.Parent.Parent.Parent.Name == 'PlayerGui'

local camera = workspace.CurrentCamera
camera.CameraSubject = game.Workspace.Cam.CameraPart
camera.CameraType = "Scriptable"
camera.CoordinateFrame= CFrame.new(game.Workspace.Cam.CameraPart.Position)
camera.CameraType = "Fixed"
camera.Focus=CFrame.new(4.4, 0.5, 85.4)

print(game.Workspace:FindFirstChild(script.seat.Value))

I want make a minigame. Infinite loop will run the game. Once player escaped Seat (that way i am doing it) infinite loop stops. Scripts not final, but right now I have problem above.

1 comment

2

Instead of using GetFullName and storing the Object's location as a String, just use an ObjectValue and store a reference the the Object itself. That way, evne if the ancestry changes you still have an absolute reference to that object.