Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't this gui morph script work? [closed]

Asked by 8 years ago

Hello! I'm new to this site and i've came here after I can't understand why this won't work. Basically, what my script does is that when you click a screengui, the script will morph you into a set morph within the gui's parent. Maybe this screenshot will explain it better.

https://gyazo.com/87949704e9752be2a5ae7763f4515408

The gui itself looks like this. The gui that is supposed to morph the character is the archer gui.

https://gyazo.com/2c133542a4489ef0fcb8b438d76a9880

The code that morphs the player is


wait() -- Variables local sp = script.Parent local reset = sp.ResetAppearance local debounce = true -- Functions script.Parent.MouseButton1Click:connect(function(touched) local body = sp.PartFolder:GetChildren() local player = game.Players:GetPlayerFromCharacter(script.Parent) if player and debounce == true then debounce = false if reset.Value == true then local charparts = touched.Parent:GetChildren() for i,v in pairs(charparts) do if v:IsA("Hat") or v:IsA("Model") then v:Destroy() elseif v:IsA("BasePart") then v.Transparency = 1 for i2,v2 in pairs(v:GetChildren()) do if v2:IsA("Decal") then v2:Destroy() end end end end end for i,v in pairs(body) do local check = true local checkchar = touched.Parent:GetChildren() local checkparts = v:GetChildren() for i2,v2 in pairs(checkchar) do if v2.Name == v.Name then check = false end end local charpart = touched.Parent:findFirstChild(string.sub(v.Name,7,16)) if (#checkparts > 1 and check == true and charpart ~= nil) then local bin = Instance.new("Model") bin.Name = v.Name bin.Parent = touched.Parent local bodyclone = v:Clone() bodyclone:SetPrimaryPartCFrame(CFrame.new()) local parts = bodyclone:GetChildren() for i2,v2 in pairs(parts) do if v2 ~= bodyclone.PrimaryPart then v2.Anchored = false v2.Parent = bin local weld = Instance.new("ManualWeld") weld.Parent = v2 weld.C0 = v2.CFrame weld.Part0 = charpart weld.C1 = CFrame.new() weld.Part1 = v2 end end bodyclone:Destroy() end end wait(0.5) debounce = true end end)

I can't understand why this won't work, the output in the console is nothing. Help!

0
aw mans bad_meme 5 — 8y
0
I'm assuming the script is inside of the player's character? User#11440 120 — 8y

Closed as Too Broad by Prioxis, TheHospitalDev, and Shawnyg

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
Zeoic 40
8 years ago

Your if statement parenting most of your code will never be fired:

if player and debounce == true then

Because it is waiting for "player" to exist.

On line 16, you have this:

local player = game.Players:GetPlayerFromCharacter(script.Parent)

"Players:GetPlayerFromCharacter()" requires you give it the actual character's model. Which would be "game.workspace.[PLAYERNAME]". If it does not receive a players "character", it will return nil.

When player equals nil, your if statement will not pass.

Ad