Why don't I get coins when I place something in workspace via a script

Okay, so I made a NPC which you can talk you and he spawns in 10 eggs when he’s done with talking. Works perfectly. Only thing is that the eggs don’t change my leaderstats. And when I place when in workspace using the explorer they work how I want them to.

Please help me.

2 Likes

I think we need script, that adds coins

I already have that. How else would I get coins when I place them into workspace using the explorer?

I mean, to fix problem we need know how it works.

You mean you want me to share the script?

Anyways, this is the script:

local db = true
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
		if db == true then
			db = false
			script.Parent.Transparency = 1
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			player.leaderstats.Eggs.Value = player.leaderstats.Eggs.Value + 1
			script.Parent.Transparency = 1
		end
	end	
end)

db = true

Why you are making script.Parent transparent twice?
And why you are making db = true in the end of this script?

I could try deleting those parts, i’ll come back later

The problem can be that you are moving parts using local script. Anything created by local script can’t edit server side like leaderstats. Try to move parts using normal script

I haven’t thought of that. I’ll try that

Okay, it works, but if I spawn in those eggs, can other players see them aswell?

Maybe try player.leaderstats.Eggs.Value += 1?

Try using test with 2 or more players, i think yes they can

How do I make it so it does work, but other cant see it?

i think you can spawn it using local player, but then you need to use local script with remote event inside eggs