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

Tool handle doesn't show ingame?

Asked by 9 years ago

Well, I've put my tools in ReplicatedStorage in hopes that it would hold the tools safely. I have also tried Lighting but nothing worked. What I meant by "safely" is that the Handle of the tool would actually show up in game. These tools are simple one piece swords that show up in studio but not ingame.

Here's the script. Can you spot anything wrong?

local p = game.Players.LocalPlayer
repeat wait() until p.Character
local c = p.Character
c.Torso.Anchored = true
h = c.Humanoid
BG = script.Parent.Frame
light = BG.Assassin
balanced = BG.Knight
heavy = BG.Tank
local h = c.Humanoid
face = c.Head:FindFirstChild("face")
repeat wait() until face
face:remove()
game.StarterGui:SetCoreGuiEnabled(4, false)
game.StarterGui:SetCoreGuiEnabled(2, true)
game.StarterGui:SetCoreGuiEnabled(3, true)
if p.TeamColor == BrickColor.new("Bright red") then
    spawner = Workspace["Red spawners"]:GetChildren()
elseif p.TeamColor == BrickColor.new("Bright blue") then
    spawner = Workspace["Blue spawners"]:GetChildren()
end
local function Spawn()
    spawn = spawner[math.random(1, #spawner)]
    c:MoveTo(spawn.Position)
    BG.Visible = false
    c.Torso.Anchored = false
end
light.MouseButton1Down:connect(
function()
    print("Light selected")
    local sword = game.ReplicatedStorage.Assassin:Clone()
    sword.Parent = p.Backpack
    lt = script.light:Clone()
    lt.Disabled = false
    lt.Parent = p.Backpack
    Spawn()
end
)
balanced.MouseButton1Down:connect(
function()
    print("Knight selected")
    local sword = game.ReplicatedStorage.Balanced:Clone()
    sword.Parent = p.Backpack
    kt = script.knight:Clone()
    kt.Disabled = false
    kt.Parent = p.Backpack
    Spawn()
end
)
heavy.MouseButton1Down:connect(
function()
    print("Tank selected")
    local sword = game.ReplicatedStorage.Tank:Clone()
    sword.Parent = p.Backpack
    tk = script.tank:Clone()
    tk.Disabled = false
    tk.Parent = p.Backpack
    Spawn()
end
)

1 answer

Log in to vote
0
Answered by
Nymint 85
9 years ago

If they don't show ingame it's most likely because you need to use ":WaitForChild()" method on every single Object (EVERY SINGLE ONE) you're going to locate, because it waits for that child first, Most localscripts are fired before a certain object shows up.

Since it's a LocalScript (Client-only) Which is almost instant, First:

LocalScript

c.Head:FindFirstChild("face") -- No.
c:WaitForChild("Head"):WaitForchild("face") --Yes.

Script

c.Head:FindFirstChild("face") -- Yes.
c:WaitForChild("Head"):WaitForchild("face") --Yes.

It works in Studio solo because Studio solo runs by Client and not a Server.

Second:

local Storage=Game:GetService("ReplicatedStorage")

Also recomended to use Game:GetService("Players").LocalPlayer, it's efficient and you get easily used to it.

Ad

Answer this question