I made a Morph for my airport, But the code isn't working. Can someone tell me why? Thanks
function onTouched(hit) local h = hit.Parent:findFirstChild("Humanoid") if (h ~= nil and debounce == true) then local g = script.Parent.Parent:findFirstChild("SAS-Uniform") debounce = false p = g.Pants:clone() s = g.Shirt:clone() p.Parent = hit.Parent s.Parent = hit.Parent wait(1) debounce = true end end
Firstly, You have made the function but haven't called it? You could use:
1)
function onTouched(hit) local h = hit.Parent:findFirstChild("Humanoid") if (h ~= nil and debounce == true) then local g = script.Parent.Parent:findFirstChild("SAS-Uniform") debounce = false p = g.Pants:clone() s = g.Shirt:clone() p.Parent = hit.Parent s.Parent = hit.Parent wait(1) debounce = true end end script.Parent.Touched:connect(onTouched)
or
2)
script.Parent.Touched:connect(function(hit) local h = hit.Parent:findFirstChild("Humanoid") if (h ~= nil and debounce == true) then local g = script.Parent.Parent:findFirstChild("SAS-Uniform") debounce = false p = g.Pants:clone() s = g.Shirt:clone() p.Parent = hit.Parent s.Parent = hit.Parent wait(1) debounce = true end end)
Then you need to define debounce
as you have used it but not defined it?
You need to define this before the function, so at line 1 you would add debounce = True
Ta-da! It works. Comment if anything is wrong.
I made this for my game. This basically Sets You To Join as A Grey Robloxian. Change the colours to what you want. Then make a pad, so when you touch it, the clothes get cloned from Lighting or whatever.
--made by tonyv game.Workspace.ChildAdded:connect(function(plr) local name = plr.Name local playerinplayers = game.Players:FindFirstChild(plr.Name) if playerinplayers ~= nil then playerinplayers.CanLoadCharacterAppearance = false plr.Head.face.Texture = "rbxassetid://13033308" local bodycolors = Instance.new("BodyColors", plr) bodycolors.RightArmColor = BrickColor.new("Pastel brown") --change to whatever colour. bodycolors.LeftArmColor = BrickColor.new("Pastel brown") bodycolors.LeftLegColor = BrickColor.new("Dark stone grey") bodycolors.RightLegColor = BrickColor.new("Dark stone grey") bodycolors.TorsoColor = BrickColor.new("Dark Stone grey") bodycolors.HeadColor = BrickColor.new("Pastel brown") end end)
This is also another one. For This one, it more complex. You need to get shirts and pants from somewhere. I got mine off Uncopylocked Phantom Forces.
local team1 = game.Teams:findFirstChild("NameOfTeam") -- Change it to your team names. local team2 = game.Teams:findFirstChild("NameOfTeam") -- put the team name, not color local t1shirt = game.Lighting:findFirstChild("NameOfTeam1Shirt") -- change to name of shirt. local t2shirt = game.Lighting:findFirstChild("NameOfTeam2Shirt") local t1pants = game.Lighting:findFirstChild("NameOfTeam1Pants")-- put EXACT name. Also Put the clothes in Lighting local t2pants = game.Lighting:findFirstChild("nameOfTeam2Pants")-- what i did was got a uncopylocked phantom Forces and copied the clothes and put own asset Id. -- you get an asset id from catalog. In the url, there are numbers. rbxassetid:// (instert numbers after slashes) --put the clothes and pants in lighting and put their name there -- NO NEED TO CHANGE ANYTHING AFTER THIS LINE function onSpawn(player) wait(1) -- takes time for the clothes to load local clothing = player.Character:GetChildren() for i = 1, #clothing do -- my favorite line in scripting, this is so uesful in everything if clothing[i].className == "Pants" or clothing[i].className == "Shirt" then clothing[i]:remove() -- removes the clothes of course end end if player.TeamColor == team1.TeamColor then t1shirt:Clone().Parent = player.Character-- it clones the clothes out of Lighting and puts them on every player on that team t1pants:Clone().Parent = player.Character -- puts uniforms into the person end if player.TeamColor == team2.TeamColor then t2shirt:Clone().Parent = player.Character t2pants:Clone().Parent = player.Character end end -- dont change the last bit unless you know what you are doing. function A(new) -- this function connects the player to the function above whenever the person respawns new.Changed:connect(function(N) if N == "Character" then onSpawn(new) end end) end game.Players.ChildAdded:connect(A) --Made By TonyV537. If you need any help, please PM me.
So Make it so there are spawn points that have AllowTeamChangeOnTouch = true. So When You Touch it, you become a part of that team. Then, either make it so when u touch the spawn, u die, so you reset and spawn with the clothes you need