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

Quest system not rewarding points, help?

I've made a quest system and it works fine. Only downside is that I'm not able to add a reward so if a player completes a quest it just completes and doesn't give any leaderstats points. I've altered the script a bit and it runs fine in studio but when I tested it on it's own then it doesn't give me any points. Heres the script:

script.Parent.Touched:connect(function(k)
	if k and k.Parent.Humanoid and game.Players[k.Parent.Name].Quest.Value == "go touch the other brik" then
		game.Players[k.Parent.Name].Quest.Value = "[Completed]"
		wait(1.1) 
		 game.Players.LocalPlayer.leaderstats.Neutros.Value = game.Players.LocalPlayer.leaderstats.Neutros.Value + 200
		end
end)

1 answer

you are trying to get localplayer in a server script ? lol Also it's better to use the GetPlayerFromCharacter function cause it's possible that the character name could have been changed

script.Parent.Touched:connect(function(touchedpart)
	local player = game.Players:GetPlayerFromCharacter(touchedpart.Parent)
	if player then
		if player.Quest.Value == "go touch the other brik" then
			player.Quest.Value = "[Completed]"
			player.leaderstats.Neutros.Value = player.leaderstats.Neutros.Value + 200
		end
	end
end)

3 comments

0

GetPlayerFromCharacter is mainly better because it only detects players, and not just every single thing that has a humanoid inside it.

0

Also, use :Connect as :connect is deprecated.

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