Help with Iron Man suit calling system

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Hello there! I’m trying to make a Iron Man suit calling menu like Iron man Simulator 2 or Iron Man: Legacy. I’ve got the suit calling working and I feel like I just messed up something somewhere but I don’t know why and I’ve been stuck on this for a few hours.

  2. What is the issue? Include screenshots / videos if possible!
    So basicly whenever you press one of the three buttons, one of the three suits depending on the button will be called to you and welded to the player. Now I have this debounce (calledSuit) to check if the suit was called to prevent someone from calling a suit over and over but for some reason the Humanoid.Died() event only works after the player has resetting atleast once. This results in my entire system breaking and I can’t figure out why.
    https://i.gyazo.com/5fcedfc3328b6d5a7974ef5acd06197a.mp4

  3. What solutions have you tried so far?
    I tried looking it up on Youtube, asking for help in HiddenDevs, searched on internet, couldn’t find anything related to my problem (If I overlooked please let me know!)

--Server script
-- Services --
local UIS = game:GetService("UserInputService")
local SS = game:GetService("ServerStorage")
local REPS = game:GetService("ReplicatedStorage")

-- Variables --
local SuitsFolder = SS:WaitForChild("Suits")
local suitOne = SuitsFolder.DefaultIron
local suitTwo = SuitsFolder.Suittwo
local suitThree = SuitsFolder.SuitThree

local chosenSuit

-- Events --
local events = REPS:WaitForChild("IronEvents")
local sendSuitEvent = events.SendSuit
local suitchoice = events.SuitChoice


local function sendSuit_player(player)
	local character = player.Character
	local cloneSuit = chosenSuit:Clone()

	cloneSuit.Parent = character

	for _, i in pairs(cloneSuit:GetChildren()) do
		if i:IsA("BasePart") then
			spawn(function()
				local trail = SS.FlyTrail
				local trailClone = trail:Clone()
				trailClone.Parent = i
				trailClone.Enabled = true
				local trailAtt0 = Instance.new("Attachment")
				trailAtt0.Name = "trailAtt0"
				trailAtt0.Parent = i
				trailAtt0.CFrame = CFrame.new(0, 0, 0.65)
				
				local trailAtt1 = Instance.new("Attachment")
				trailAtt1.Name = "trailAtt1"
				trailAtt1.Parent = i
				trailAtt1.CFrame = CFrame.new(0, 0, -0.85)
				
				trailClone.Attachment0 = trailAtt0
				trailClone.Attachment1 = trailAtt1
				local AP = Instance.new("AlignPosition")
				AP.Parent = i
				local att0 = Instance.new("Attachment")
				att0.Parent = i
				local att1 = Instance.new("Attachment")
				att1.Parent = character:FindFirstChild(i.Name)

				i.Anchored = false
				i.CanCollide = false
				AP.Attachment0 = att0
				AP.Attachment1 = att1

				while true do
					task.wait()
					if (i.Position - character:FindFirstChild(i.Name).Position).Magnitude < 3 then
						if not i:FindFirstChild("Weld") then
						local weld = Instance.new("Weld")
						weld.Parent = i
						weld.Part0 = i
						weld.Part1 = character:FindFirstChild(i.Name)
						end
						AP.Enabled = false
						AP:Destroy()
						att1:Destroy()
						att0:Destroy()
						trailClone:Destroy()
						trailAtt0:Destroy()
						trailAtt1:Destroy()
						if not AP:FindFirstChild("AlignPosition") then
							break
						end
					end
				end
			end)
			task.wait(.2)
		end
	end
end

suitchoice.OnServerEvent:Connect(function(plyr, suit)
	if suit == "DefaultIron" then
		print(plyr.Name.. " chose: DefaultIron (server)")
		chosenSuit = suitOne
		sendSuit_player(plyr)
	elseif suit == "SuitTwo" then
		print(plyr.Name.. " chose: SuitTwo (server)")
		chosenSuit = suitTwo
		sendSuit_player(plyr)
	else
		print(plyr.Name.. " chose: SuitThree (server)")
		chosenSuit = suitThree
		sendSuit_player(plyr)
	end
end)

sendSuitEvent.OnServerEvent:Connect(function(player)
	sendSuit_player(player)
end)
--Client script
-- Services --
local UIS = game:GetService("UserInputService")
local REPS = game:GetService("ReplicatedStorage")

-- Variables --
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local ui = script.Parent.Parent.PlayerGui.IronManGui
local Button1 = ui.Frame.ScrollingFrame.DefaultIron
local Button2 = ui.Frame.ScrollingFrame.SuitTwo
local Button3 = ui.Frame.ScrollingFrame.SuitThree
local calledSuit = false
local isOpen = false

-- Events --
local events = REPS:WaitForChild("IronEvents")
local sendSuitEvent = events.SendSuit
local suitchoice = REPS.IronEvents.SuitChoice


local function sendSuit()
	print(calledSuit)
	if not calledSuit then
		calledSuit = true
		print(calledSuit)
		sendSuitEvent:FireServer()
	end
end


UIS.InputBegan:Connect(function(input, chatting)
	if not chatting then
		if input.KeyCode == Enum.KeyCode.Q then
			sendSuit()
		end
	end
end)


player.Chatted:Connect(function(message)
	if string.lower(message) == string.lower("Send suit") then
		print("Sending suit!")
		sendSuit()
	end
end)


player.CharacterAdded:Connect(function(char)
	local Human = player.Character:WaitForChild("Humanoid")
	Human.Died:Connect(function()
		calledSuit = false
		print("Someone died, calledSuit: ".. tostring(calledSuit))
		print(calledSuit)
	end)
end)


local function openGui()
	if isOpen == false then
		isOpen = true
		ui.Enabled = true
	else
		ui.Enabled = false
		isOpen = false
	end
end


UIS.InputBegan:Connect(function(input, chatting)
	if not chatting then
		if input.KeyCode == Enum.KeyCode.G then
			openGui()
		end
	end
end)


Button1.MouseButton1Click:Connect(function()
	print(calledSuit)
	if calledSuit == false then
		suitchoice:FireServer("DefaultIron")
		print("chose: DefaultIron (client)")
		calledSuit = true
		ui.Enabled = false
	end
end)


Button2.MouseButton1Click:Connect(function()
	print(calledSuit)
	if calledSuit == false then
		suitchoice:FireServer("SuitTwo")
		print("chose: SuitTwo (client)")
		calledSuit = true
		ui.Enabled = false
	end
end)


Button3.MouseButton1Click:Connect(function()
	print(calledSuit)
	if calledSuit == false then
		suitchoice:FireServer("SuitThree")
		print("chose: SuitThree (client)")
		calledSuit = true
		ui.Enabled = false
	end
end)

If anyone is so nice to try and help me out here, I’ve been waiting for a week and I still haven’t figured it out, please help.

Hey bro, I think the problem is with the variables: ui and buttons. When the player dies, there is a change in the PlayerGui that affects the MouseButton1Click call.
Try using this Client script that updates the variables when the character is loaded:

--Client script
-- Services --
local UIS = game:GetService("UserInputService")
local REPS = game:GetService("ReplicatedStorage")
local PLRS = game:GetService("Players")

-- Variables --
local calledSuit = false
local isOpen = false

-- Events --
local events = REPS:WaitForChild("IronEvents")
local sendSuitEvent = events.SendSuit
local suitchoice = REPS.IronEvents.SuitChoice


PLRS.LocalPlayer.CharacterAdded:Connect(function(character)
	local player = PLRS:GetPlayerFromCharacter(character)
	local Human = character:WaitForChild("Humanoid")
	local ui = player.PlayerGui:WaitForChild("IronManGui")
	local Button1 = ui.Frame.ScrollingFrame.DefaultIron
	local Button2 = ui.Frame.ScrollingFrame.SuitTwo
	local Button3 = ui.Frame.ScrollingFrame.SuitThree

	local function sendSuit()
		print(calledSuit)
		if not calledSuit then
			calledSuit = true
			print(calledSuit)
			sendSuitEvent:FireServer()
		end
	end

	UIS.InputBegan:Connect(function(input, chatting)
		if not chatting then
			if input.KeyCode == Enum.KeyCode.Q then
				sendSuit()
			end
		end
	end)

	player.Chatted:Connect(function(message)
		if string.lower(message) == string.lower("Send suit") then
			print("Sending suit!")
			sendSuit()
		end
	end)


	Human.Died:Connect(function()
		calledSuit = false
		print("Someone died, calledSuit: ".. tostring(calledSuit))
		print(calledSuit)
	end)

	local function openGui()
		if isOpen == false then
			isOpen = true
			ui.Enabled = true
		else
			ui.Enabled = false
			isOpen = false
		end
	end


	UIS.InputBegan:Connect(function(input, chatting)
		if not chatting then
			if input.KeyCode == Enum.KeyCode.G then
				openGui()
			end
		end
	end)


	Button1.MouseButton1Click:Connect(function()
		print(calledSuit)
		if calledSuit == false then
			suitchoice:FireServer("DefaultIron")
			print("chose: DefaultIron (client)")
			calledSuit = true
			ui.Enabled = false
		end
	end)


	Button2.MouseButton1Click:Connect(function()
		print(calledSuit)
		if calledSuit == false then
			suitchoice:FireServer("SuitTwo")
			print("chose: SuitTwo (client)")
			calledSuit = true
			ui.Enabled = false
		end
	end)


	Button3.MouseButton1Click:Connect(function()
		print(calledSuit)
		if calledSuit == false then
			suitchoice:FireServer("SuitThree")
			print("chose: SuitThree (client)")
			calledSuit = true
			ui.Enabled = false
		end
	end)
end)

Thank you so much! It looks like it works! I appreciate it. Now I can work on helmet functionallity and flying! (sorry for late response I was on vacation :smile: )

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.