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

Tycoon buy button script isnt working?

I dont really get remove() but i see it on tycoons so i tried to make a buy button myself.

keeps saying WoodMine (the name of the item) is not a valid member of DataModel

any help?

script.Parent.Touched:connect(function(hit)
	local item = script.Parent.Parent.Item.Value
	if hit.Parent.Humanoid ~= nil then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player.leaderstats.Money.Value > script.Parent.Parent.Price.Value or player.leaderstats.Money.Value == script.Parent.Parent.Price.Value then
			game[item].Parent = script.Parent.Parent.Parent
		end
	end
end)

2 answers

game[item].Parent = script.Parent.Parent.Parent

It's probably because the WoodMine is not in the game, if it is in Workspace then you should put:

game.Workspace[item].Parent = script.Parent.Parent

Replace Workspace depending on where it is.

The problem is that WoodMine isn't a member of DataModel, as you said. DataModelis the proper name for game. DataModel holds services only. So on line 6 of the code, you should change gameto where the model is being held, most likely in the Workspace. Some code as to what I mean:

script.Parent.Touched:connect(function(hit)
    local item = script.Parent.Parent.Item.Value
    if hit.Parent.Humanoid ~= nil then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player.leaderstats.Money.Value >= script.Parent.Parent.Price.Value then -- Here I use the >= (greater than or equal to) operator.
            workspace[item].Parent = script.Parent.Parent.Parent
        end
    end
end)

1 comment

0

WoodMine is not a valid member of workspace...

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