repeat wait() until script.Parent.Product.Value~=nil
local product=script.Parent.Product.Value:clone()
script.Parent.Product.Value:remove()
script.Parent.Parent["Upgrade - 450"].Head.CanCollide=false
script.Parent.Parent["Upgrade - 450"].Head.Transparency=1
local price=script.Parent.Price.Value
script.Parent.Head.Touched:connect (function(hit)
local chr=hit.Parent
if chr:findFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(chr) then
local plr=game.Players:GetPlayerFromCharacter(chr)
if plr.Name==script.Parent.Parent.Parent.OwnerName.Value and plr.leaderstats.Money.Value>=price then
plr.leaderstats.Money.Value=plr.leaderstats.Money.Value-price
product.Parent=script.Parent.Parent.Parent
script.Parent.Parent["Upgrade - 450"].Head.CanCollide=true
script.Parent.Parent["Upgrade - 450"].Head.Transparency=0
script.Parent:remove()
end
end
end)
Alright, so ideally, at the beginning of the script, it will set up button2 that is dependent on the button1 being pressed. I set the values of Button2 to: Transparancy=1 and CanCollide=false so that in theory, the button2 could not be pressed, or touched in a way that would trigger its own Touch Command to spawn its "Upgrade - 450", and once button1 is pressed and the player had enough money, the "Upgrade - 450" Head would have CanCollide=true and its Transparency=0, so button2 could be pressed.
When I try the script, the transparency values work, however I can still walk over the location where button2 is, and it detects my collission runs its script, even though I don't want it to, until button 1 has been pressed.
Am I just doing this wrong? Can I not set up a Touched:connect function to be dependent on direct collision between player and block?
