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

Changing a StringValue?

Asked by
Mystdar 352 Moderation Voter
10 years ago

I have put a Stringvalue in the player, called : QuestProgress The String's base value is: None I want so that when a player touches a part the string value changes, but struggled to do it on my own, probably because i'm acting like it is a IntValue. The script in the part is:

script.Parent.Touched:connect(function(player)
        print (player.Parent.Name) --This would print the name of the person who touched the brick
        local Player_name = player.Parent.Name
        local Quest=script.Parent
        Quest:remove()  -- Haven't tested the remove part, because the script wasn't working without it, anyway.
        game.Players[Player_name].CurrentQuest.Value=game.Players[Player_name].CurrentQuest.Value.Finding Apples -- I think this is the problem 
    end)

I have tried this for the last line too:

game.Players[Player_name].CurrentQuest.Value=game.Players[Player_name].CurrentQuest.Value."Finding Apples"

To no prevail. Thanks.

1 answer

Log in to vote
1
Answered by
RoboFrog 400 Moderation Voter
10 years ago

Try this line in place of 6 --

game.Players:GetPlayerFromCharacter(player).CurrentQuest.Value = "Apples"

Assuming that's what you're attempting to do, it should work.

This is because in a touched function, it returns the Character player (game.Workspace), not the game.Players player. By using Players:GetPlayerFromCharacter(player), it'll then reformat the game.Workspace character into the game.Players player.

And, when setting string values (assuming you were trying to just do this), all you need is the text you want to set it to in "".

(Excuse anything that might seem obvious in explanation -- I'd rather over explain than under explain)

EDIT After examining the issue more thoroughly, it seems that the way you're setting your string is the true issue.

0
That part would still work in his original code. But your code is still correct, just more efficient. Tkdriverx 514 — 10y
0
Hmm, that is true. I'm not used to the player being called in that manner. RoboFrog 400 — 10y
0
Got it, thanks, my only problem is that the part deletes itself as soon as I play solo, if I remove the 3rd and 4th lines, it works, any suggestions? Mystdar 352 — 10y
0
Would that not be because of "Quest:remove()"? Or are you saying that it just deletes itself as soon as you join the game without touching the button? (in solo) RoboFrog 400 — 10y
0
Yeah, as soon as I join without touching. Mystdar 352 — 10y
Ad

Answer this question