Attempt to call a string value [Camping Game]

So I’m making a camping game but I run into this problem “Attempt to call a string value”

Here is the script, the problem is on Line 41

local Gui = game.StarterGui:FindFirstChild("DialogGui")
local Frame = Gui:FindFirstChild("Frame")
local TextValue = game.ReplicatedStorage:FindFirstChild("TextValue")
local SpeakerText = Frame:FindFirstChild("Title")
local PlayerImage = Frame:FindFirstChild("PlayerImage")
local RandomPlayer
local Text

function TypeSound()
    local Sound = Instance.new("Sound")
    Sound.Parent = game.Workspace
    Sound.Name = "TypeSound"
    Sound.SoundId = "http://www.roblox.com/asset/?id=3333976425"
    Sound.PlaybackSpeed = 1
    Sound.Volume = 0.5
    Sound:Play()
    coroutine.resume(coroutine.create(function()
        wait(1)
        Sound:Destroy()
    end))
end

function Text(word)
    Text = word
    for i = 1, #Text do
        TextValue.Value = string.sub(Text, 1, i)
        TypeSound()
        wait(0.05)
    end
end

wait(20)
print("Running Text")
Frame.Visible = true
RandomPlayer = game.Players:GetChildren()[math.random(1, #game.Players:GetChildren())]
SpeakerText.Text = RandomPlayer.Name
Text("Hello and welcome to Part 9!")
PlayerImage.Image = game.Players:GetUserThumbnailAsync(RandomPlayer.userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
wait(5)
SpeakerText.Text = RandomPlayer.Name
Text("I am a random player!")
wait(5)
Frame.Visible = false
print("Finish")

If you’re wondering, this is what the properties look like
Screenshot 2020-06-02 at 10.43.30 am

Note I make the text change through the Value in ReplicatedStorage because if I hook up the text straight to the TextLabel it causes bugs, but that’s not a concern.

I’ve been trying to fix this for the past 30 or so minutes but come into more problems. I understand that the solution might be simple but I would appreciate help :smiley:

I don’t understand why it wouldn’t work although between your first SpeakerText.Text and your second edit you call

However you will get the same player again because you have defined RandomPlayer beforehand meaning it would be the same person again. Also if the line is on 41 could you show the error that appears within the function?

1 Like

I am aware of the random person issue but I’m concentrating on getting the mechanics finished

This is what it says in the output
Screenshot 2020-06-02 at 11.04.33 am

Which line exactly is this error occurring? I get that you said Line 41, but which is that without us counting?

Now I see why, You have defined “Text” as a Variable and also as a Function. Essentially what’s happening is on the first time the Text function is ran you are then changing the Text function to a Variable which is holding string. This means the second time you try to do this because Text is now a variable and not a function it won’t work. To fix this simply just change the variable/function name so it’s unique to the other identifier.

3 Likes

Oh, I see now but why was it working on the first Text function

Hererererererererererererererer

1 Like

Because after you did “local Text” you then immediately redefined it to a Function, and since it wasn’t edited to anything else before then it would just run the first time.

2 Likes

You didnt type anything in the variable so it didnt work. You Type = “local Text”
you needed to say something what the variable.

Thats not the problem, you can still leave variables blank. It’s only blank because you can change the variable in other lines