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

Why will this GUI that tells the player they need to select a sword not move into position?

Asked by
Txeer 46
4 years ago

I am making a sword fighting game and don't want the Intro GUI to go away until you select a sword. If you don't have a sword in your backpack the GUI will not disappear when you hit the "play" button and will instead bring up a GUI that tells the player they need to select a sword before continuing. The script works except it won't move the GUI that tells the player they need to select a sword into position. Any ideas?


-- Variables local looky = game.Workspace.CurrentCamera local player = game.Players.LocalPlayer local char = player.Character local hum = char:WaitForChild("Humanoid") local storage = game:GetService("ReplicatedStorage") -- This segment is what I'm having trouble with (near else) script.Parent.Playbutton.MouseButton1Click:Connect(function() local backpack = game.Players.LocalPlayer.Backpack for i, child in pairs(backpack:GetChildren()) do if child:IsA("Tool") then storage.RemoteEvents.MobileOn:FireServer() script.Parent.Visible = false repeat wait() looky.CameraType = Enum.CameraType.Custom until looky.CameraType == Enum.CameraType.Custom else script.Parent.Parent.NoSword.Position = UDim2.new(0.321, 0,0.321, 0) end end end) hum.Died:Connect(function() wait(5) storage.RemoteEvents.MobileOff:FireServer() repeat wait() looky.CameraType = Enum.CameraType.Scriptable until looky.CameraType == Enum.CameraType.Scriptable repeat wait() looky.CFrame = game.Workspace.startingcamerapos.CFrame until looky.CFrame == game.Workspace.startingcamerapos.CFrame script.Parent.Visible = true end)
0
Are there any errors that show up when you try running it? killerbrenden 1537 — 4y
0
If the backpack has no children then it will not run through that for loop. Since they do not have a sword yet I assume the backpack is empty so your for loop does not run. ForeverBrown 356 — 4y
0
I'd use :FindFirstChild() to find if there is a sword inside the players backpack. ForeverBrown 356 — 4y
0
Yes, he is right. If there are no swords in the backpack, then the script won't run. Make sure you have a sword in StarterPack so they spawn with a sword. killerbrenden 1537 — 4y

Answer this question