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

What is wrong with my script?

objects = {} wait(1)

script.Parent:WaitForChild("Buttons") for i,v in pairs(script.Parent.Buttons:GetChildren()) do if v:FindFirstChild("Head") then

	local oject	= script.Parent.Purchases:FindFirstChild(v.Object.Value)	
	if objects ~= nil then
		objects[object.Name] = object:Clone{}
		object:Destory()
	else
		print("Button: "..v.Name.." is missing its object and has been removed.")
		v.CanCollide =  false
		v.Transparency = 1
end
	
	v.Head.Touched:connect(function(hit)
		local player =  game.PlayersGetPlayerFromCharacter(hit.Parent)
		if v.Head.CanCollide == true
			if player ~= nil then
				if script.Parent.Owner.Value == player then
					if hit.Parent:FindFirstChild("Humanoid") then
						if hit.Parent.Humanoid.Health > 0 then
							local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
							if cashmoney ~= nil then
								if cashmoney.Value >= v.Price.Value then
									cashmoney.Value = cashmoney.Value - v.Price.Value
									objects[v.Object.Value].Parent= script.PurchasedObjects
									v.Head.CanCollide =  false
									v.Head.Transparency = 1
								end
							end
						end
					end
				end
			end
			end
		end)
	end
end

3 comments

0

it says " if player ~= nil then" is incorrect. the "if" is on line 14

0

Can you get the whole thing inside the code block?

0

'local oject = script.Parent.Purchases:FindFirstChild(v.Object.Value)' 'oject' Typo?

1 answer

object is spelled incorrectly as oject on (what is currently) line 1.

game.PlayersGetPlayerFromCharacter is written on line 12; it should read game.Players:GetPlayerFromCharacter.

if v.Head.CanCollide == true is missing then after it on line 13.

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