Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I make this script change a stringvalue?

I'm trying to change a value inside of a player? (The script is isnide of a GUI)

Script :

function onClicked(Player)
	Player:FindFirstChild("Class").Value = Player:FindFirstChild("Class").Value = "Knight"
end

Dosen't work...

2 answers

✓ Accepted answer

The function has nothing to call it, nor is it being called.

Use this:

-- Assuming this script is in a GUI button.

function onClicked(Player)
	Player:FindFirstChild("Class").Value = Player:FindFirstChild("Class").Value = "Knight"
end

script.Parent.MouseButton1Click:connect(onClicked)

1 comment

0

Omg, i always forget to do that lmao, thanks

I recommend using variables, using "local"

This MIGHT work:

function onClicked(Player)
    local class = Player:FindFirstChild("Class")
     class.Value = "Knight"
end

script.Parent.MouseButton1Click:connect(onClicked)

But, you didn't declare what "Player" is. I recommend the following, but use a LocalScript:

function onClicked(Player)
     local Player = game.Players.LocalPlayer
    local class = Player:FindFirstChild("Class")
     class.Value = "Knight"
end

script.Parent.MouseButton1Click:connect(onClicked)

Please comment if you have questions!

This discussion is preserved as it was. New answers, comments, and votes are closed.