I'm making a hotel type thing and I want to make it so once a player clicks a door they own it and they can open and close it whenever they want. I also want to make it so that it dosen't kill other players they just can't get in and so that a player can only claim one room per server. I'm pretty bad at this stuff so please tell me where to put the scripts and stuff too. Thank you.
COMMUNITY QUESTION
How to make a click to be owner door?
1 answer
Try out my owner-part script, this should work if you put the script in a part.
I just wrote this so I don't know what the errors/down-sides of using this is yet. I hope this works for you!
local Players = game:GetService("Players")
local OwnablePart = script.Parent
local ClickDetector = Instance.new("ClickDetector")
local ToggleCollision = function(Part)
if Part.CanCollide == false then
Part.CanCollide = true
Part.Transparency = 0
else
Part.CanCollide = false
Part.Transparency = .5
end
end
ClickDetector.MouseClick:Connect(function(Player)
if Player:FindFirstChild("OwnsADoor") then
local OwnsADoor = Player["OwnsADoor"]
if OwnsADoor:IsA("ObjectValue") and OwnsADoor.Value == OwnablePart then
ToggleCollision(OwnablePart)
print("This door is yours, toggling the door...");
end
else
for _,OtherPlayer in pairs(Players:GetPlayers()) do
if OtherPlayer ~= Player and OtherPlayer:FindFirstChild("OwnsADoor") and OtherPlayer["OwnsADoor"].Value == OwnablePart then
print("You do not own this door.");
return
end
end
local OwnsADoor = Instance.new("ObjectValue")
OwnsADoor.Name = "OwnsADoor"
OwnsADoor.Value = OwnablePart
ToggleCollision(OwnablePart)
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
not a request site try it yourself