Dictionary scripting

Okay so I have a game and was wondering how to make it so for example a part how do I make it so if a person touches 3 diff parts how would I make it open a door and make it so the door will be open to that person and not all?

Use a local script. So the door will be open only for that client and not for the rest.

but like how to make it so they would have to click three diff parts that you can find around the game?

This is an example:

local part = --put your part here
local door = --put your door here
part.Touched:Connect(function(hit)
	if hit == game:GetService("Players").LocalPlayer.Character then
		door.Transparency = 0.5
		door.CanCollide = false	
	end
end)

would it work though if the way to do it is that you press 3 different parts for it to open and not just one?

This?

local part1 = --put your part here
local part2 = --put your part here
local part3 = --put your part here
local touchedPart1 = false
local touchedPart2 = false
local touchedPart3 = false

local character = game:GetService("Players").LocalPlayer.CharacterAdded:Wait()
local door = --put your door here

part1.Touched:Connect(function(hit)
	if hit == character then		
		partTouched1 = true
	end

	if partTouched2 and partTouched3 then
		door.Transparency = 0.5
		door.CanCollide = false
	end
end)

part2.Touched:Connect(function(hit)
	if hit == character then
		partTouched2 = true
	end
	
	if partTouched1 and partTouched3 then
		door.Transparency = 0.5
		door.CanCollide = false
	end
end)

part3.Touched:Connect(function(hit)
	if hit == character then
		partTouched3 = true
	end
	
	if partTouched2 and partTouched3 then
		door.Transparency = 0
		door.CanCollide = false
	end
end)
1 Like

Yes. But how do i make this work? Because I’m just test this out with this script so I can learn but it won’t work because of this : local character = game:GetService(“Players”).LocalPlayer.CharacterAdded:Wait()

I tested the script and it works well for me.

But how come the local character = game:GetService(“Players”).LocalPlayer.CharacterAdded:Wait() won’t work? is there something certain I have to do?

Where is the LocalScript at?

Its inside of ServerStorage think I might of done that wrong XD

No, put it inside the StarterPlayerScripts, which is within the StarterPlayer

Oh XD thank you I didn’t know that

Does the script work? If not, tell me ;D

Here’s what I have and it still won’t work :confused:

Ok

local part1 = workspace.Part1
local part2 = workspace.Part2
local part3 = workspace.Part3
local touchedPart1 = false
local touchedPart2 = false
local touchedPart3 = false

local player = GetService(_Players_).LocalPlayer
local character = player.CharacterAdded:Wait()
player.CharacterAdded:Connect(function(char)
	character = char
end
local door = workspace.Door

part1.Touched:Connect(function(hit)
	if hit.Parent == character then		
		partTouched1 = true
	end

	if partTouched2 and partTouched3 then
		door.Transparency = 0.5
		door.CanCollide = false
	end
end)

part2.Touched:Connect(function(hit)
	if hit.Parent == character then
		partTouched2 = true
	end
	
	if partTouched1 and partTouched3 then
		door.Transparency = 0.5
		door.CanCollide = false
	end
end)

part3.Touched:Connect(function(hit)
	if hit.Parent == character then
		partTouched3 = true
	end
	
	if partTouched2 and partTouched3 then
		door.Transparency = 0
		door.CanCollide = false
	end
end)

? whats this??? Will it help? :confused: :innocent:

That is most certainly not how you script touched events. You would use GetPlayerFromCharacter function. Also touch event returns that body part that touched it, not the model.

Does the script works now???

No because some of the words have errors