|
| 27 Aug 2015 07:49 PM |
if armor.Value == true then --[[ print(IsArmor) armorcheck() print(IsArmor) wait(1) --]] if Humanoid and char:FindFirstChild("Chest") == nil then local g = script.Parent.Parent.Chest:Clone() g.Parent = char local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" 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 = char.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
------------------------------------- A snippet of code from my script ^ When you click a button, you get armor parts welded to you. This code works online in my test place. It works online in my test place's studio. It works online in my main game place's studio, but not online there. Anyone detecting any errors here? There's another snippet of code that adds health to a player and that works, but not this. So I'm very confused. You guys see anything wrong with this code? |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 07:54 PM |
| This is not the whole script. armor and armorcheck() function is undefined. |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 07:55 PM |
"A snippet of code from my script ^"
I figured if I posted the entire script people wouldn't read it because it's too long. The armor value is true and the armorcheck function is commented out so ignore it. Here's the entire script if you want it:
player = game.Players.LocalPlayer repeat wait() until player.Character char = player.Character Humanoid = char:WaitForChild("Humanoid") statnumbers = player:WaitForChild("statnumbers") armorstats = player:WaitForChild("armorstats") armor = armorstats:WaitForChild("IronArmor") Defense = script.Parent.Parent:FindFirstChild("Defense") playerdef = statnumbers:WaitForChild("Def")
--[[ armorcheck = function() for i,v in pairs(char:GetChildren()) do if v.Name == "Chest" or v.Name == "Leg1" or v.Name == "Leg1" or v.Name == "Arm1" or v.Name == "Arm2" then return true end end return false end IsArmor = armorcheck() --]] script.Parent.MouseButton1Click:connect(function() if armor.Value == true then --[[ print(IsArmor) armorcheck() print(IsArmor) wait(1) --]] if Humanoid and char:FindFirstChild("Chest") == nil then local g = script.Parent.Parent.Chest:Clone() g.Parent = char local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" 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 = char.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 if Humanoid and char:FindFirstChild("Leg1") == nil then local g = script.Parent.Parent.Leg1:Clone() g.Parent = char local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" 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 = char["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 Humanoid and char:FindFirstChild("Leg2") == nil then local g = script.Parent.Parent.Leg2:Clone() g.Parent = char local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" 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 = char["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.MouseButton1Click:connect(function() if not char:FindFirstChild("Defense") then script.Parent.Parent.Defense:Clone().Parent = char Humanoid.MaxHealth = Humanoid.MaxHealth + Defense.Value wait(.1) Humanoid.Health = Humanoid.MaxHealth playerdef.Value = playerdef.Value + Defense.Value end end) |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 07:59 PM |
Where is this script located?
I'm getting 'script.Parent.Parent.Chest:Clone()'
Is this in a replicated storage? server storage? |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Aug 2015 08:04 PM |
| The second click function where it adds health works, just the first one where it welds arms and chest doesn't work |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 08:08 PM |
player = game.Players.LocalPlayer repeat wait(0.045) until player.Character char = player.Character Humanoid = char:WaitForChild("Humanoid") statnumbers = player:WaitForChild("statnumbers") armorstats = player:WaitForChild("armorstats") armor = armorstats:WaitForChild("IronArmor") Defense = script.Parent.Parent:FindFirstChild("Defense") playerdef = statnumbers:WaitForChild("Def")
otherwise, idk. There's something in that statement that's causing the script not to work. |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 08:11 PM |
| wait 0.045 instead of wait()? ill try it but i doubt it. thanks for the help anyway bro |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 08:14 PM |
| Ye..nope. Guess I'll make them brick morphs instead since this won't work :/ sucks cause i spent a lot of time on making it in GUI form but whatever |
|
|
| Report Abuse |
|
|