This works in single player, But does not work in multiplayer. The Gui cannot detect the player that touches the Detector Part. When A player touches, It will show Me their names. However it doesn't. May this be a bad script?

local player = game.Players.LocalPlayer
repeat wait() until player.Character

local mci = script.Parent.Parent.Parent.MCI.Value
local detect = script.Parent.Detect
local yesNo = script.Parent.yesno
local seat = script.Parent.Parent.SeatAssign
local detecting = script.Parent.Parent.Parent.Detecting


mci.Detector.Touched:connect(function(hit)
	if not (detecting.Value == true) then return end
	
	if hit.Parent == player.Character  then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		
		if player.Backpack.Booked.Value == false then
			detecting.Value = false
			
			detect.Text = "Check in "..player.Name.."?"
			seat.User.Value = player.Name
			yesNo.Yes.Visible = true
			yesNo.No.Visible = true
			detect:TweenPosition(UDim2.new(0, 10, 0.5, -40) , "Out", "Sine", 0.5)
			wait(0.5)
			yesNo:TweenPosition(UDim2.new(0.5, -70, 0.5, 5), "Out", "Sine", 0.5)	
		elseif (player.Backpack.Booked.Value == true) then
			detecting.Value = false
			detect.Text = player.Name.." Is already checked in! (2)"
			wait(1)
			detect.Text = player.Name.." Is already checked in! (1)"
			wait(1)
			detect.Text = player.Name.." Is already checked in! (0)"
			wait(1)
			detect.Text = "Detecting Player"
			detecting.Value = true
		end
		wait(1)
	end
end)


--[[mci.Detector.Touched:connect(function(hit)
	if not (detecting.Value == true) then return end
	
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		
		if player.Backpack.Booked.Value == false then
			detecting.Value = false
			
			detect.Text = "Check in "..player.Name.."?"
			seat.User.Value = player.Name
			yesNo.Yes.Visible = true
			yesNo.No.Visible = true
			detect:TweenPosition(UDim2.new(0, 10, 0.5, -40) , "Out", "Sine", 0.5)
			wait(0.5)
			yesNo:TweenPosition(UDim2.new(0.5, -70, 0.5, 5), "Out", "Sine", 0.5)	
		elseif (player.Backpack.Booked.Value == true) then
			detecting.Value = false
			detect.Text = player.Name.." Is already checked in! (2)"
			wait(1)
			detect.Text = player.Name.." Is already checked in! (1)"
			wait(1)
			detect.Text = player.Name.." Is already checked in! (0)"
			wait(1)
			detect.Text = "Detecting Player"
			detecting.Value = true
		end
		wait(1)
	end
end)
]]--

yesNo.No.MouseButton1Click:Connect(function()
	detect:TweenPosition(UDim2.new(0, 10, 0.5, -20), "Out", "Sine", 0.5)
	yesNo:TweenPosition(UDim2.new(0.5, -70, 1, 0), "Out", "Sine", 0.5)
	detect.Text = "Cooldown (2)"
	wait(1)
	detect.Text = "Cooldown (1)"
	wait(1)
	detect.Text = "Cooldown (0)"
	wait(1)
	detect.Text = "Detecting Player"
	wait(1)
	detecting.Value = true	
	seat.User.Value = ""
end)

2 comments

0

I'd assume this is a local script correct?

0

^ Yep.