I'm trying to make a flare gun and I have a pretty good system set up. I have a debounce timer that prevents the client from spamming it and it tries to display a "Reloading!" gui, but fails. I have the script properly set up and there are no errors, and the print statement inside is running, but no GUI is being instanced.
Local Script:
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character
local camera = workspace.CurrentCamera
local event = game.ReplicatedStorage.FlareEvent
local debounce = false
local guiparent = game.StarterGui.WeaponGUI.ReloadFrame
player.CharacterAdded:Connect(function(toset)
character = toset
end)
local i = 0
local sound = script.Parent:WaitForChild("flare sound")
local tool = script.Parent
local acceleration = 20
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if character:FindFirstChild("Flare Gun") then
if debounce == false then
sound:Play()
event:FireServer()
debounce = true
wait(1)
debounce = false
else
print("Reloading!")
local text = Instance.new("TextLabel")
text.Text = "Reloading!"
text.Transparency = 0
text.Font = Enum.Font.TitilliumWeb
text.BackgroundTransparency = 1
text.Position = UDim2.new(50, 1, 50, 1)
text.Parent = guiparent
repeat
text.Transparency = text.Transparency + 0.1
i += 1
wait(0.05)
until i > 10
i = 0
text:Destroy()
end
end
end
end)
The script fires a remote event if debounce is false, and prints "Reloading!" when debounce is true. When I check the hierarchy in-game, I can see that nothing is being instanced to "guiparent". I've made sure that "guiparent" is pointing towards a real section of the hierarchy.
I've tried instancing and I expected it to "summon" a text label. What happened was nothing, nothing happened.
StarterGui is only a storage for the GUI, Roblox will internally clone each GUI in StarterGui to the player's PlayerGui (e.g. game > Players > Builderman > PlayerGui)
To solve this, change guiparent to
local guiparent = player.PlayerGui:WaitForChid("WeaponGUI").ReloadFrame