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

im trying to make a like lose ingredients and make cake but it doenst seem to work please help me?

if game.Players.LocalPlayer.leaderstats.Ingredients.Value > 1 then script.Parent.Activated:Connect(function()

local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)

plr.leaderstats.Ingredients.Value = plr.leaderstats.Ingredients.Value -1
plr.leaderstats.Cake.Value = plr.leaderstats.Cake.Value +1

end) end

2 answers

You have everything you need, but you have placed it in the wrong order. If this is a server script, the local player cannot be accessed. So you must use :GetPlayerFromCharacter, like you did later in the script.

script.Parent.Activated:Connect(function()

	local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)

	if plr.leaderstats.Ingredients.Value >1 then
		plr.leaderstats.Ingredients.Value = plr.leaderstats.Ingredients.Value -1
		plr.leaderstats.Cake.Value = plr.leaderstats.Cake.Value +1
	else

	end
end)

1 comment

0

"script.Parent.Activated" so this is probally a tool(Local Script)

Is this in a regular script or local script? If it is server script , LocalPlayer cannot be used.

1 comment

0

Why didn't you posted a comment?

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