I have 2 scripts. A house owner script and a keycard giver script. How do I mash these 2 together to make 1 script?
House script:
local ting = 0 --debouncer
owner = script.Parent.Parent.Parent.OwnerName --This is the thing that holds the owners name
function onTouched(hit)
if ting == 0 then --debounce check
ting = 1 --activate debounce
check = hit.Parent:FindFirstChild("Humanoid") --Find the human that touched the button
if check ~= nil then --If a human is found, then
local user = game.Players:GetPlayerFromCharacter(hit.Parent) --Find human among the players
if (user:FindFirstChild("House") ~= nil) then
local user = game.Players:GetPlayerFromCharacter(hit.Parent) --Find human among the players
local message = Instance.new("Message") --make a message
message.Text = "You already own a House" --Put text into the message
message.Parent = user --Display message to new owner only
wait(3) --Wait to let the message display for a while
message:remove() --Remove the message from the new owner
else
local user = game.Players:GetPlayerFromCharacter(hit.Parent) --Find human among the players
owner.Value = hit.Parent.Name --save new owners name for later.
local own = Instance.new("IntValue")
own.Name = "House"
own.Parent = user
local message = Instance.new("Message") --make a message
message.Text = "You now own this House!" --Put text into the message
message.Parent = user --Display message to new owner only
wait(3) --Wait to let the message display for a while
message:remove() --Remove the message from the new owner
script.Parent.Parent:remove()
end
end
ting = 0 --remove debounce
end
end
script.Parent.Touched:connect(onTouched) --Start listening for button-touchers.
Keycard giver script
print("Shop Script Loaded")
Door = script.Parent
local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouched(hit)
if debounce == false then
local human = hit.Parent:findFirstChild("Humanoid")
if (human == nil) then return end
local player = getPlayer(human)
debounce = true
if (player == nil) then return end
local stats = player:findFirstChild("leaderstats")
local sp = stats:findFirstChild("Money")
if sp == nil then return false end
if (sp.Value >=0) then --Amount of how much the weapon will go for
sp.Value = sp.Value - 0 --Put the same exact number here as you did above
print("Enough Money")
game.Lighting.Keycard13:clone().Parent = player.Backpack --Change NAMEOFTOOLHERE to your tool name
Door.BrickColor = BrickColor.new(37) --MAKE SURE YOU PUT THE WEAPON INTO LIGHTING
wait(2)
Door.BrickColor = BrickColor.new(21) --Leave the rest of this alone
debounce = false
else debounce = false
end
end
end
connection = Door.Touched:connect(onTouched) --

3 comments
Please be a bit more specific, did you make these scripts yourself?
Not really.
I used a few tutorials on how to make these scripts.