local NPC = script.Parent.Parent
local FoodFOlder = game.ReplicatedStorage.Order_Possible
local AvabFood = FoodFOlder:GetChildren()
local ChosenFood = AvabFood[math.random(1,#AvabFood)]
local hitting = ChosenFood.Name
local NPCActive = game.ReplicatedStorage.NPC_Possible
local AvabNPC = NPCActive:GetChildren()
local ChosenOne = AvabNPC[math.random(1,#AvabNPC)]
local Online = ChosenOne
wait(5)
NPC.Humanoid:MoveTo(game.Workspace.NPCA.Point1.Position)
NPC.Humanoid.MoveToFinished:Wait()
wait(0)
NPC.Humanoid:MoveTo(game.Workspace.NPCA.Point2.Position)
NPC.Humanoid.MoveToFinished:Wait()
wait(0)
NPC.Humanoid:MoveTo(game.Workspace.NPCA.Point3.Position)
--checks that correct was given
NPC.Head.Order.order.Text = "Hi! Can I have a "..ChosenFood.Name.." please!"
script.Parent.Touched:Connect(function(Hit)
if Hit.Parent.Name == hitting then
Hit.Parent:Destroy()
NPC.Humanoid:MoveTo(game.Workspace.NPCA.Point4.Position)
NPC.Humanoid.MoveToFinished:Wait()
game.Players.LocalPlayer.leaderstats.WorkerPoint.Value = game.Players.LocalPlayer.leaderstats.WorkerPoint.Value + 1
--removes NPC at end
script.Parent.Parent:Destroy()
wait(10)
local Clone = Online:Clone()
Clone.Parent = workspace
wait(5)
end
end)
How does your game work. Anyplayer can give them the food? Or does each player have an individual store that they give food to the npc? When a player places down the food, you should insert an object value that’s value is the player who placed the food down. Then when the npc hits it, get the player from the object value.
Ah, here’s what we can do then: Get the Player Object by using GetPlayerFromCharacter function which will then change the leaderstats to the server-side that way, the only issue I see is the Hit.Parent which I’m assuming is referring to the ChosenFood variable so you may have to do Hit.Parent.Parent instead?