Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make map visible to one player?

So I tried to make the map visible to one player but apparently, all of the players can see it. I did put the local script in the StarterGui and the Filtering Enabled is on.

workspace.Entrance.Part01.Touched:Connect(function()
	if not workspace.CurrentCamera:FindFirstChild("RoadMap") then
    	   game.ReplicatedStorage.RoadMap:Clone().Parent = workspace.CurrentCamera
	end
end)

1 answer

✓ Accepted answer

Hey buddy!

I've always hated these types of issues and they're very annoying to fix, but let me help ya!

First, I need to teach you about RemoteEvents. RemoteEvents are the bypasser of this type of issue, as they're able to pass information from the entire server to only one player.

In this case, it would help you!

Secondly, insert a RemoteEvent into the ReplicatedStorage and name it however you like. Put a regular script inside and type in:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:WaitForChild("Humanoid",10) then -- checking if the touching guy is a player
		local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- getting the player by using the character
		game.ReplicatedStorage.RemoteEventNameHere:FireClient(player) --The thing inside the brackets are telling the remoteEvent who to fire it to, so in this case, the player!
	end
end)

Lastly, insert a LocalScript into the StarterGui and then type in:

game.ReplicatedStorage.RemoteEventNameHere.OnClientEvent:Connect(function() --listening for the remote event
	-- code here
end)

To learn more about RemoteEvents, go to here

3 comments

0

Thanks, it's working now :)

0

But the scripts don't work in the map when I clone it, is there a way to fix this?

0

I don't know, though. Try researching more, That I can't help with.

This discussion is preserved as it was. New answers, comments, and votes are closed.