What do you want to achieve? I would like to make sure that when both players touch their parts then the door opens only for those two players
What is the issue? I created a remote Event to open the door as I was advised to do, but the script doesn’t work unfortunatly
What solutions have you tried so far? I tried to modify the scripts, I tried to put the remote Events script locally and not locally, I tried different things without success (remote function…). (I am still a beginner)
--Local Script in StarterCharacterScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local opendoor = ReplicatedStorage:WaitForChild("opendoor2")
opendoor.OnClientEvent = function(player, part)
game.Workspace.Door2.Transparency = 1
end
And there is the second script
--Script in ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local opendoor = ReplicatedStorage:WaitForChild("opendoor2")
local part = game.Workspace.Door2
local transparent = function()
opendoor:FireClient(part)
end;
game.Workspace.Clef.Touched:Connect(function(hit)
if hit.Parent.Name == "Wrench2" then
game.Workspace.Clefv.Material = Enum.Material.Neon
if game.Workspace.Clefv.Material == Enum.Material.Neon and game.Workspace.Clefv3.Material == Enum.Material.Neon then
transparent()
end
end
end)
game.Workspace.Clef3.Touched:Connect(function(hit)
if hit.Parent.Name == "Wrench3" then
game.Workspace.Clefv3.Material = Enum.Material.Neon
if game.Workspace.Clefv.Material == Enum.Material.Neon and game.Workspace.Clefv3.Material == Enum.Material.Neon then
transparent()
end
end
end)
please if someone can help me to achieve this. Thanks
If someone can go into more detail, because I can’t seem to get any benefit from their advice. Thanks
Edit: Maybe if you know a good video tutorial adapted to my subject?
game.Workspace.Clef.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if hit.Parent.Name == "Wrench2" then
game.Workspace.Clefv.Material = Enum.Material.Neon
if game.Workspace.Clefv.Material == Enum.Material.Neon and game.Workspace.Clefv3.Material == Enum.Material.Neon then
transparent()
end
end
end
end)
it’s quite difficult for me in the sense that it’s the first time I’m trying to make a script work this way, and like everything else on roblox until you get the script right the first time then it’s not easy to understand the logic behind
Ye, here is a better indented version, and debugged
game.Workspace.Clef.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
print("We have a player")
if hit.Parent.Name == "Wrench2" then
print("We stepped in Wrench2")
game.Workspace.Clefv.Material = Enum.Material.Neon
if game.Workspace.Clefv.Material == Enum.Material.Neon and game.Workspace.Clefv3.Material == Enum.Material.Neon then
print("We can call the transparent function")
transparent()
end
end
end
end)
game.Workspace.Clef.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
print("We have a player")
game.Workspace.Clef.Touched:Connect(function(hat)
if hat.Parent.Name == "Wrench2" then
print("We stepped in Wrench2")
game.Workspace.Clefv.Material = Enum.Material.Neon
if game.Workspace.Clefv.Material == Enum.Material.Neon and game.Workspace.Clefv3.Material == Enum.Material.Neon then
print("We can call the transparent function")
transparent()
end
end
end)
end
end)
but now it block here
local transparent = function()
opendoor:FireClient(part)
end;
I have an idea for the transparent function try this:
local transparent = function(player)
opendoor:FireClient(player, part)
end;
And for the other part just do this:
game.Workspace.Clef.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
print("We have a player")
game.Workspace.Clef.Touched:Connect(function(hat)
if hat.Parent.Name == "Wrench2" then
print("We stepped in Wrench2")
game.Workspace.Clefv.Material = Enum.Material.Neon
if game.Workspace.Clefv.Material == Enum.Material.Neon and game.Workspace.Clefv3.Material == Enum.Material.Neon then
print("We can call the transparent function")
transparent(player)
end
end
end)
end
end)
First you need to use touched events and debounces. Then you need to wait for 1 player to be on each part. Then you fire both those clients and use a local script with RemoteEvents.
--Local Script in StarterCharacterScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local opendoor = ReplicatedStorage:WaitForChild("opendoor2")
opendoor.OnClientEvent = function(player)
game.Workspace.Door2.Transparency = 1
end
Does i need to change something in this ?
if i put on the other script
local transparent = function(player)
print("open")
end;
it print “open” in the output but if i put
local transparent = function(player)
opendoor:FireClient(player, part)
print("hiii")
end;
I was able to exchange with a developer who helped me but unfortunately the action is still blocked at the time of the fireclient. Here are the new scripts
--ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local opendoor = ReplicatedStorage:WaitForChild("opendoor2")
local debounce = 1
local transparent = function(player)
opendoor.FireClient(player)
end;
game.Workspace.Clef.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
print("We have a player")
if hit.Parent:FindFirstChild("Wrench2") then
print("We stepped in Wrench2")
game.Workspace.Clefv.Material = Enum.Material.Neon
if game.Workspace.Clefv.Material == Enum.Material.Neon and game.Workspace.Clefv3.Material == Enum.Material.Neon then
print("We can call the transparent function")
transparent(player)
end
end
end
end)
game.Workspace.Clef3.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
print("We have a player")
if hit.Parent:FindFirstChild("Wrench3") then
game.Workspace.Clefv3.Material = Enum.Material.Neon
if game.Workspace.Clefv.Material == Enum.Material.Neon and game.Workspace.Clefv3.Material == Enum.Material.Neon then
transparent(player)
end
end
end
end)
--LocalScript in StarterCharacter
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local opendoor = ReplicatedStorage:WaitForChild("opendoor2")
opendoor.OnClientEvent = function(player)
game.Workspace.Door2.Transparency = 1
end
if you have an idea what’s the problem ? Thank you