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

How to make a GUI inside .Touched only change for one person?

When a player touches the part the GUI (fadeScreen) is supposed to only change for the player that touched the part, but it changes for all players.

This is a local script inside StarterGui

local player = game.Players.LocalPlayer
local playergui = player:WaitForChild("PlayerGui")
local fadeScreen = playergui.Travel.FadeScreen

place = CFrame.new(206.25, -159.5, -1833)


function fadeIn(GUI)
	
	fadeScreen.Visible = true
	fadeScreen.BackgroundTransparency = 1
	
	for i = 1, 150 do
      wait(0.01)
      fadeScreen.BackgroundTransparency = fadeScreen.BackgroundTransparency - 0.01
	end
	
end



game.Workspace.Part1.Touched:Connect(function(hit)
	
	if debounce == false then return end
	debounce = false
	
	if hit then
    if hit.Parent:FindFirstChild('Humanoid') and game.Players:FindFirstChild(hit.Parent.Name) then
	
	local plr = game.Players:FindFirstChild(hit.Parent.Name)
	
	fadeIn()
	plr.Character.HumanoidRootPart.CFrame = place
	
    end
    end
	
	wait(10)
	debounce = true
end)

1 answer

✓ Accepted answer

For realise this, i propose use RemoteEvent.

Put in ReplicatedStorage a RemoteEvent. In ur part put a ServerScript "Script". In this script write this.

local Event = game:GetService('ReplicatedStorage').RemoteEvent

script.Parent.Touched:Connect(function(hit)
	local Player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
	if Player then
		Event:FireClient(Player)
	end
end)

now that this is done, in ur ClientScript "LocalScript" write this.

local Event = game:GetService('ReplicatedStorage').RemoteEvent

local Player = game:GetService('Players').LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local fadeScreen = PlayerGui.Travel.FadeScreen

Debounce = true
place = Vector3.new(206.25, -159.5, -1833)

function fadeIn()
	
	fadeScreen.Visible = true
	fadeScreen.BackgroundTransparency = 1
	
	for i = 1, 150 do
		wait(0.01)
		fadeScreen.BackgroundTransparency = fadeScreen.BackgroundTransparency - 0.01
	end
end

Event.OnClientEvent:Connect(function()
	if Debounce then
		Debounce = false
		fadeIn()
 		Player.Character:MoveTo(place)
		Debounce = true
	end
end)

I'm on mobile so I could not test but it should work.

Accepte my awnser if it work.

1 comment

1

Works like a charm! Thank you!

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