Hello! I'm very new to LUA, and technically, this is not my coding- I am simply part of the team working on revising this game for its new players!
Currently, everything is working as it should, except for one part, our custom decal morph gui. When you load in the decal's code, whatever it may be, and input the height, width, and position- it simply makes your player invisible. Help?
Here is the related code in ServerScriptService
ReplicatedStorage = game:GetService("ReplicatedStorage")
prefix = "rbxassetid://"
function morphPlayer(player,img,width,height,position)
--=====================================
local httpService = game:GetService('HttpService')
local function GetAsync(Url)
local reqResults = {}
ypcall(function ()
reqResults = { httpService:GetAsync(Url) }
end)
return unpack(reqResults)
end
local function GetImageFromDecal(DecalId)
local ImageID = GetAsync("https://www.classy-studios.com/APIs/GetImage.php?ID="..DecalId)
if (ImageID and ImageID ~= "No image found for provided DecalId") then
return ImageID
end
end
local requestedImage = GetImageFromDecal(img)
if requestedImage then
print(requestedImage)
else
print('Image not found')
end
--=====================================
print ((prefix)..(requestedImage))
local fullURL = (prefix)..(requestedImage)
--== CHECK FOR ALREADY-EQUIPPED MORPH
if player.Character:findFirstChild("Chest") then player.Character.Chest:remove()end
if player.Character:findFirstChild("Humanoid") ~= nil then
--=== APPLY DECALS
local chest = game.ServerStorage.Morphs.Default.Chest:Clone()
chest.Middle.Decal1.Texture = fullURL
chest.Middle.Decal2.Texture = fullURL
--== APPLY SIZING/POSITIONING
chest.Middle.Mesh.Scale = Vector3.new(width,height,0.05)
chest.Middle.Mesh.Offset = Vector3.new(0,position,0)
--== APPLY LOCATION
chest.Parent = player.Character
--=== REMOVE HATS
local a = player.Character:GetChildren()
for i=1, #a do
if (a[i].className == "Part") then
a[i].Transparency = 1
elseif (a[i].className == "Accessory") then
a[i]:remove()
end
--== WELD TO PLAYER
local children = chest:GetChildren()
for i=1, #children do
if children[i].className == "Part" then
local W = Instance.new("Weld")
W.Part0 = chest.Middle
W.Part1 = children[i]
local CJ = CFrame.new(chest.Middle.Position)
local C0 = chest.Middle.CFrame:inverse()*CJ
local C1 = children[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = chest.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = player.Character.Torso
Y.Part1 = chest.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
--== UNANCHOR IT
local child = chest:GetChildren()
for i = 1, # child do
if child[i].className == "Part" then
child[i].Anchored = false
-- child[i].CanCollide = false
end
end
end
--== PLAY SOUND
print("successfully morphed into "..img)
local sound = script.Sound:Clone()
sound.Parent = player.Character
sound:Play()
wait (2)
sound:Destroy()
end
end
ReplicatedStorage.OC.OnServerEvent:Connect(morphPlayer)
Here is the script for the TextButton to confirm your decal.
wait (2)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage.OC
local textbox = script.Parent.Parent.Decal
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local width = script.Parent.Parent.Width
local height = script.Parent.Parent.Height
local position = script.Parent.Parent.PositionButton
MAX = 3
MAXNEG = -3
textlabel = script.Parent.Parent.TextLabel
script.Parent.MouseButton1Down:connect(function()
print ("Input: "..textbox.Text)
print ("Width: "..width.Text)
print ("Height: "..height.Text)
print ("Position: "..position.Text)
local NUMwidth = tonumber(width.Text)
local NUMheight = tonumber(height.Text)
local NUMposition = tonumber(position.Text)
local NUMimg = tonumber(textbox.Text)
if NUMwidth > MAX or NUMwidth < MAXNEG then
textlabel.Visible = true
script.Sound:Play()
textlabel.Text = "MAX WIDTH EXCEEDED! (Maximum: "..MAX..")"
wait(4)
textlabel.Visible = false
return "max width exceeded"
elseif NUMheight > MAX or NUMheight < MAXNEG then
textlabel.Visible = true
script.Sound:Play()
textlabel.Text = "MAX HEIGHT EXCEEDED! (Maximum: "..MAX..")"
wait(4)
textlabel.Visible = false
return "max height exceeded"
elseif NUMposition > MAX or NUMposition < MAXNEG then
textlabel.Visible = true
script.Sound:Play()
textlabel.Text = "MAX POSITION OFFSET EXCEEDED! (Maximum: "..MAX..")"
wait(4)
textlabel.Visible = false
return "max position exceeded"
elseif NUMheight < MAX and NUMwidth < MAX and NUMposition < MAX
and NUMheight > MAXNEG and NUMwidth > MAXNEG and NUMposition > MAXNEG then
RemoteEvent:FireServer(NUMimg,NUMwidth,NUMheight,NUMposition)
script.Parent.Parent.Decal.Text = "" --clear text
wait(2)
local decal = player.Character.Chest.Middle:FindFirstChildOfClass("Decal")
if decal ~= nil then
script.Parent.Parent.ImageLabel.Image = decal.Texture
else wait (2)
if decal ~= nil then
script.Parent.Parent.ImageLabel.Image = decal.Texture
else wait (2)
if decal ~= nil then
script.Parent.Parent.ImageLabel.Image = decal.Texture
end
end
end
end
end)
I've only begun to understand most of the variables here, so any help is greatly appreciated! Thank you for taking the time to read this. :)
