Problem with loading a room

Whats the problem?
I have created a LocalScript under StarterGUI, when you touch a part a room will load and when you are not touching it loads out. Although I a struggling to make this only happen for one player, this happens for the whole server even though its’ a local script. Is there a way to make this only load for certain players?

The part is inside a folder named “Render”.

local Player = game.Players.LocalPlayer
local RenderFolder = game.ReplicatedStorage.RenderUpstairs
local Part = workspace.Render.one

Part.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
		RenderFolder.Parent = workspace
	end
end)

Part.TouchEnded:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
		RenderFolder.Parent = game.ReplicatedStorage
	end
end)
1 Like

I’m not sure but maybe it could do with the fact that you move RenderFolder to Workspace, resulting in everyone seeing it.

Is there anywhere I could put it so only the LocalPlayer can see it?

Try this:

local Player = game.Players.LocalPlayer
local RenderFolder = game.ReplicatedStorage.RenderUpstairs
local Part = workspace.Render.one

local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

Part.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent:FindFirstChild("Humanoid") == Humanoid then
		RenderFolder.Parent = workspace
	end
end)

Part.TouchEnded:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent:FindFirstChild("Humanoid") == Humanoid then
		RenderFolder.Parent = game.ReplicatedStorage
	end
end)

All it does is checks whether or not the Humanoid is the Local Players Humanoid.

Thanks works perfectly! Been looking for a solution for ages.

1 Like