How To Make The Hostile NPC Recognize and gives exp to the killer?
Asked by
6 years ago Edited 6 years ago
hello there ,
so recently im planning to make a rpg game
and when testing using roblox studio play mode
but im having trouble with the stats system that gives exp when a player killed a npc
the script in the weapon (using regular script and it also says the player cant be found) :
01 | local tool = script.Parent |
02 | local candamage = tool:WaitForChild( "CanDamage" ) |
03 | local player = game.Players.LocalPlayer |
05 | tool.Blade.Touched:connect( function (p) |
07 | local hum = char:FindFirstChild( "Humanoid" ) |
08 | local hitsound = tool:WaitForChild( "Hit" ) |
09 | if candamage.Value = = false then |
11 | candamage.Value = true |
13 | hum.Health = hum.Health - script.Dmg.Value |
15 | candamage.Value = false |
16 | local tag = Instance.new( "StringValue" ,p.Parent.Humanoid) |
18 | tag.Value = player.Name |
the one inside the npc (using script):
1 | local human = script.Parent:WaitForChild( "Humanoid" ) |
2 | human.Died:connect( function () |
3 | local tag = human.Parent:FindFirstChild( "creator" ) |
5 | game.ReplicatedStorage.Events.Geee:Fire( 10 ,human.creator.Value) |
it keeps saying it cant find the creator tag
i hope it can give the player 10 exp when the player kills it
Edit: I saw the comments that i should use Event to add the tag to the npc but how do i exactly do that?