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

How would I make this script change a stringvalue?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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)
0
Omg, i always forget to do that lmao, thanks KennySfromTitan 106 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

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!

Answer this question