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) :
local tool = script.Parent
local candamage = tool:WaitForChild("CanDamage")
local player = game.Players.LocalPlayer
tool.Blade.Touched:connect(function(p)
local char = p.Parent
local hum = char:FindFirstChild("Humanoid")
local hitsound = tool:WaitForChild("Hit")
if candamage.Value == false then
if hum then
candamage.Value = true
hitsound:Play()
hum.Health = hum.Health - script.Dmg.Value
wait(1)
candamage.Value = false
local tag = Instance.new("StringValue",p.Parent.Humanoid) -- creates new value
tag.Name = "creator" -- sets the name
tag.Value = player.Name -- sets it to the name of the killer (i hope)
end
end
end)
the one inside the npc (using script):
local human = script.Parent:WaitForChild("Humanoid")
human.Died:connect(function()
local tag = human.Parent:FindFirstChild("creator")
if tag then
game.ReplicatedStorage.Events.Geee:Fire(10,human.creator.Value)--gee is a bindable event so far i haven't got an error in the output but if there's a mistake please help me :( im still new to scripting
end
end)
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?

11 comments
Does you game use FE ? If yes the first script (in the weapon) should be a local script because Players.LocalPlayer can't be accessed with a regular script. And you should use remote event/function to spawn the tag.
https://www.developer.roblox.com/articles/Remote-Functions-and-Events
kid make the npc remember the person that last hit it, then once the npc dies award points to the player. this encourages competition in the game.
your making local tag = Instance.new("StringValue",p.Parent.Humanoid) have a parent early
Also instead of hum.Health = hum.Health - script.Dmg.Value, use hum:TakeDamage(script.Dmg.Value)
@TheluaBanana thats what im trying to ask
@xJathur95x Roblox Forced FE on all games on 2018 and thx for the suggestion to ill try to make it that way
@RichardP965 good job u dont even know how to do that
its ok well get there step by step
@TheluaBanana Can you teach me how to do that correctly?
k i gave a easy enough way