Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make map visible to one player?

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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

0
Thanks, it's working now :) User#26978 0 — 4y
0
But the scripts don't work in the map when I clone it, is there a way to fix this? User#26978 0 — 4y
0
I don't know, though. Try researching more, That I can't help with. Sensei_Developer 298 — 4y
Ad

Answer this question