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

Text Labels not going Visible?

Asked by 4 years ago
Edited 4 years ago

Idea: I'm trying to make it so whenever you pull out a weapon, the text at the bottom of the screen shows what weapon it is.

Problem: However, the text doesn't seem to be going visible which really confuses me. I also tried to make the labels change to whatever the string value is, but that didn't seem to work either. I'm a little new to scripting if you couldn't tell.

Thanks (I've highlighted the parts of the script that make the Gui go visible and not visible)

script:

wait(1)
local dance = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
local Player = game.Players.LocalPlayer
local Action = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.ACtion)
local Speed= 28
local DefaultSpeed= 16
local Fork = game.StarterGui.ScreenGui.TrustyFork -- Text with weapon text
local Hands = game.StarterGui.ScreenGui.Hands -- Text with weapon Text





local Tool = script.Parent


Tool.Equipped:Connect(function()
    dance:Play()
    Player.Character.Humanoid.WalkSpeed = Speed
    Fork.Visible = true -- Visible Part
    Hands.Visible = false -- Visible Part
    end)

Tool.Unequipped:Connect(function()
    dance:Stop()
    Player.Character.Humanoid.WalkSpeed = DefaultSpeed
    Hands.Visible = true -- Visible Part
    Fork.Visible = false -- Visible Part
end)


Tool.Activated:Connect(function()
    Action:Play()
    wait(1)
    dance:Play()
end)

1 answer

Log in to vote
0
Answered by 4 years ago

You don't change the GUIs from StarterGui. Everything in StarterGui clones into the Player's PlayerGui when they join. To change a player's GUIs, you would access their PlayerGui, which is a child of the player that stores all the players GUIs. You could refer to the objects as:

local player = game.Players.LocalPlayer
local trustforky = player.PlayerGui:WaitForChild("ScreenGui").TrustyFork
local hands = player.PlayerGui:WaitForChild("ScreenGui").Hands

Your script would be:

wait(1)
local Player = game.Players.LocalPlayer
local dance = Player.Character.Humanoid:LoadAnimation(script.Parent.Animation)
local Action = Player.Character.Humanoid:LoadAnimation(script.Parent.ACtion)
local Speed= 28
local DefaultSpeed= 16
local Fork = player.PlayerGui:WaitForChild("ScreenGui").TrustyFork
local Hands = player.PlayerGui:WaitForChild("ScreenGui").Hands

local Tool = script.Parent

Tool.Equipped:Connect(function()
    dance:Play()
    Player.Character.Humanoid.WalkSpeed = Speed
    Fork.Visible = true -- Visible Part
    Hands.Visible = false -- Visible Part
    end)

Tool.Unequipped:Connect(function()
    dance:Stop()
    Player.Character.Humanoid.WalkSpeed = DefaultSpeed
    Hands.Visible = true -- Visible Part
    Fork.Visible = false -- Visible Part
end)


Tool.Activated:Connect(function()
    Action:Play()
    wait(1)
    dance:Play()
end)

0
If this is a script and not local script then it won't work rushknight 17 — 4y
0
Because there is no local player to the server rushknight 17 — 4y
0
Yup, it worked. You just made a capitalization error at line 7 and 8, "player" should be "Player" Thank you so much. NovaGooBoom 42 — 4y
Ad

Answer this question