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

How would I make a button in a tycoon that replaces a model with another model?

I've been trying for a long time to make a tycoon that gradually updates an object through buying something, for example: Buy a wooden door, upgrade to glass door, upgrade to futuristic door, etc.

I took this from a tycoon kit, shortened it and tried to make it at least change the transparency and cancollide, I'm terribly bad at scripting and just starting, but I know I'm missing a lot from this script.

script.Parent.Head.Touched:connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		script.Parent.Head.Transparency = 0.0
			script.Parent.Head.CanCollide = false
		end
	end
end)		

2 comments

0

So what are you doing?

0

I said what I'm doing.

1 answer

EDITED Based on TheAlphaStigma's help First: the process this script uses to find the Player from Character doesn't work. Try

player = game.Players:FindFirstChild(hit.Parent.Name)

also 0.0 for transparency isn't necessary, just 0 should be fine. EXTRA: I don't exactly know how this is supposed to work, but consider changing the location of your script to the actual head, and changing your function to:

script.Parent.Touched:connect(function(hit)

If there's still some confusion let me know! If I helped please accept my answer! Thanks!

8 comments

1

I'll try this when ROBLOX comes back online. :)

0

alright sorry if it doesnt work, i couldnt test...

1

Neither code will work: The first, you are calling an OBJECT and not a STRING. The second, incorrect syntax, it should be 'game.Players:GetPlayerFromCharacter(hit.Parent)', also another problem with the first is; What if there was an object named the 'hit.Parent''s name, and it's not the Player?

0

thanks, I will remove my answer, I wasn't able to test this due to roblox maintenance. And I can't use F9 because I'm using a Windows 8 computer.

0

There is no reason to remove your answer, just edit your answer. :)

0

is that better? @TheAlphaStigma

0

I tried it out, but it didn't work.

0

It keeps saying line 6 is messed up.

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