-
What do you want to achieve? A morph that instantly morphs you if you touch it while meeting its requirements(currency or badge).
-
What is the issue? If i step away from the morph pad right after touching it, it only gives me the tools and nothing else. It seems to be even worse with morphs that require a badge, you don’t have to step away as quick
Video example, normal morph
Video example, badge morph
-
What solutions have you tried so far? I’ve tried doing stuff like making it not check the player’s currency for every tool and putting it into a single function but it doesn’t help.
--normal morph script--
local stats = script.Parent.Stats
local hp = stats.HP.Value
local speed = stats.WalkSpeed.Value
local jump = stats.JumpPower.Value
local cost = stats.TWPCost.Value
local allow = false
script.Parent.Touched:Connect(function(h)
local plr = game.Players:GetPlayerFromCharacter(h.Parent)
allow = false
local human = h.Parent:FindFirstChild("Humanoid")
if plr then
for i,v in pairs(game.ServerStorage.Tools.MainCharacters.OuterSans:GetChildren()) do
if v:IsA("Tool") and plr.Backpack:FindFirstChild(v.Name) == nil
and plr:WaitForChild("leaderstats"):WaitForChild("TWP").Value >= cost then allow = true
v:Clone().Parent = plr.Backpack
end
end
end
end)
--SPEED CONFIG--
function ontouch(part)
local h = part.Parent:FindFirstChild("Humanoid")
if h~= nil and allow == true then
h.MaxHealth = hp
h.Health = hp
h.WalkSpeed = speed -- Speed amount. (Default 16)
h.JumpPower = jump
end
end
script.Parent.Touched:connect(ontouch)
--TELEPORTER--
script.Parent.Touched:Connect(function(h)
local hum = h.Parent:FindFirstChild("Humanoid")
if hum ~= nil and allow == true then
h.parent.HumanoidRootPart.CFrame = CFrame.new(workspace.RandomTpBox.RandomTpPart.Position) --Change SpawnMap To the part you are teleporting to
end
end)
debounce3 = false
script.Parent.Touched:connect(function(hit)
if not debounce3 then
debounce3 = true
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum ~=nil and allow == true then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player:FindFirstChild("Sound") then
local sound = script.Parent.Sound:Clone()
sound.Parent = player.PlayerGui
sound:Play()
wait(0.5)
end
end
debounce3 = false
end
end)
debounce2 = true
function OnTouched2(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
if debounce2 == true then
if human ~= nil and script.Parent.Color ~= Color3.fromRGB(255, 0, 0) and allow == true then
debounce2 = false
script.Parent.Color = Color3.fromRGB(255, 0, 0)
wait(0.5)
debounce2 = true
script.Parent.Color = Color3.fromRGB(255, 255, 255)
end
end
end
script.Parent.Touched:connect(OnTouched2)
--run = 5643947945
--Humanoid Changes--
function onTouch2(part)
local human = part.Parent:findFirstChild("Humanoid")
if human ~= nil and allow == true then
part.Parent:findFirstChild("Head").Transparency = 1
part.Parent:findFirstChild("Torso").Transparency = 1
part.Parent:findFirstChild("Left Arm").Transparency = 1
part.Parent:findFirstChild("Right Arm").Transparency = 1
part.Parent:findFirstChild("Left Leg").CanCollide = true
part.Parent:findFirstChild("Left Leg").Transparency = 1
part.Parent:findFirstChild("Right Leg").CanCollide = true
part.Parent:findFirstChild("Right Leg").Transparency = 1
end
end
script.Parent.Touched:connect(onTouch2)
function onTouched3(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Leg1") == nil
and allow == true then
local g = script.Parent.Parent.Leg1:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "UnionOperation"or C[i].className =="Part"or C[i].className =="MeshPart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent["Left Leg"]
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Leg2") == nil
and allow == true then
local g = script.Parent.Parent.Leg2:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "UnionOperation"or C[i].className =="Part"or C[i].className =="MeshPart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent["Right Leg"]
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
script.Parent.Touched:connect(onTouched3)
function onTouched4(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Headz") == nil
and allow == true then
local g = script.Parent.Parent.Headz:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "Part" or C[i].className == "UnionOperation"or C[i].className =="MeshPart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent.Head
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
script.Parent.Touched:connect(onTouched4)
--HAT REMOVER--
function onTouched5(hit)
if allow == true then
local d = hit.Parent:GetChildren()
for i=1, #d do
if (d[i].className == "Accessory") then
d[i]:Destroy()
end
end
end
end
script.Parent.Touched:connect(onTouched5)
--FACE REMOVER--
-- declarations
local head = script.Parent
function onTouched6(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil and allow == true then
if part.Parent:findFirstChild("Head"):findFirstChild("face").Texture == nil then return end
part.Parent:findFirstChild("Head"):findFirstChild("face").Texture="717dea9c5a1659640155f77c84892c " end
end
script.Parent.Touched:connect(onTouched6)
--OTHER HUMANOID STUFF--
function onTouched7(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Chest") == nil
and allow == true then
local g = script.Parent.Parent.Chest:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "UnionOperation"or C[i].className == "Part"or C[i].className =="MeshPart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent.Torso
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
script.Parent.Touched:connect(onTouched7)
--the badge morph--
local stats = script.Parent.Stats
local badgeId = stats.BadgeID.Value
local hp = stats.HP.Value
local speed = stats.WalkSpeed.Value
local jump = stats.JumpPower.Value
local cost = stats.TWPCost.Value
local badgeservice = game:GetService("BadgeService")
local allow = false
local allow2 = false
script.Parent.Touched:Connect(function(h)
local plr = game.Players:GetPlayerFromCharacter(h.Parent)
--check for badge--
local success, hasBadge = pcall(function()
return badgeservice:UserHasBadgeAsync(plr.UserId, badgeId)
end)
if not success then
warn("Error while checking if player has badge!")
return
end
if hasBadge then
allow2 = true
end
--the rest--
local human = h.Parent:FindFirstChild("Humanoid")
if plr then
for i,v in pairs(game.ServerStorage.Tools.EventCharacters.COFPhase1:GetChildren()) do
if v:IsA("Tool") and plr.Backpack:FindFirstChild(v.Name) == nil
and allow2 == true
and plr:WaitForChild("leaderstats"):WaitForChild("TWP").Value >= cost then allow = true
v:Clone().Parent = plr.Backpack
end
end
end
end)
--SPEED CONFIG--
function ontouch(part)
local h = part.Parent:FindFirstChild("Humanoid")
if h~= nil and allow == true then
h.MaxHealth = hp
h.Health = hp
h.WalkSpeed = speed -- Speed amount. (Default 16)
h.JumpPower = jump
end
end
script.Parent.Touched:connect(ontouch)
--TELEPORTER--
script.Parent.Touched:Connect(function(h)
local hum = h.Parent:FindFirstChild("Humanoid")
if hum ~= nil and allow == true then
h.parent.HumanoidRootPart.CFrame = CFrame.new(workspace.RandomTpBox.RandomTpPart.Position) --Change SpawnMap To the part you are teleporting to
end
end)
debounce3 = false
script.Parent.Touched:connect(function(hit)
if not debounce3 then
debounce3 = true
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum ~=nil and allow == true then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player:FindFirstChild("Sound") then
local sound = script.Parent.Sound:Clone()
sound.Parent = player.PlayerGui
sound:Play()
wait(0.5)
end
end
debounce3 = false
end
end)
debounce2 = true
function OnTouched2(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
if debounce2 == true then
if human ~= nil and script.Parent.Color ~= Color3.fromRGB(255, 0, 0) and allow == true then
debounce2 = false
script.Parent.Color = Color3.fromRGB(255, 0, 0)
wait(0.5)
debounce2 = true
script.Parent.Color = Color3.fromRGB(255, 255, 255)
end
end
end
script.Parent.Touched:connect(OnTouched2)
--run = 5643947945
--Humanoid Changes--
function onTouch2(part)
local human = part.Parent:findFirstChild("Humanoid")
if human ~= nil and allow ==true then
part.Parent:findFirstChild("Head").Transparency = 1
part.Parent:findFirstChild("Torso").Transparency = 1
part.Parent:findFirstChild("Left Arm").Transparency = 1
part.Parent:findFirstChild("Right Arm").Transparency = 1
part.Parent:findFirstChild("Left Leg").CanCollide = true
part.Parent:findFirstChild("Left Leg").Transparency = 1
part.Parent:findFirstChild("Right Leg").CanCollide = true
part.Parent:findFirstChild("Right Leg").Transparency = 1
end
end
script.Parent.Touched:connect(onTouch2)
function onTouched3(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Leg1") == nil and allow == true then
local g = script.Parent.Parent.Leg1:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "UnionOperation"or C[i].className =="Part"or C[i].className =="MeshPart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent["Left Leg"]
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Leg2") == nil and allow == true then
local g = script.Parent.Parent.Leg2:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "UnionOperation"or C[i].className =="Part"or C[i].className =="MeshPart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent["Right Leg"]
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
script.Parent.Touched:connect(onTouched3)
function onTouched4(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Headz") == nil and allow == true then
local g = script.Parent.Parent.Headz:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "Part" or C[i].className == "UnionOperation"or C[i].className =="MeshPart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent.Head
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
script.Parent.Touched:connect(onTouched4)
--HAT REMOVER--
function onTouched5(hit)
if allow == true then
local d = hit.Parent:GetChildren()
for i=1, #d do
if (d[i].className == "Accessory") then
d[i]:Destroy()
end
end
end
end
script.Parent.Touched:connect(onTouched5)
--FACE REMOVER--
-- declarations
local head = script.Parent
function onTouched6(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil and allow == true then
if part.Parent:findFirstChild("Head"):findFirstChild("face").Texture == nil then return end
part.Parent:findFirstChild("Head"):findFirstChild("face").Texture="717dea9c5a1659640155f77c84892c " end
end
script.Parent.Touched:connect(onTouched6)
--OTHER HUMANOID STUFF--
function onTouched7(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Chest") == nil and allow == true then
local g = script.Parent.Parent.Chest:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "UnionOperation"or C[i].className == "Part"or C[i].className =="MeshPart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent.Torso
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
script.Parent.Touched:connect(onTouched7)