|
| 01 Feb 2014 03:48 PM |
I have this script so that when someone touches the part it gives them money. The part then has to fade out. The "give money" part works fine but the fade out doesn't work at all. The object still gets destroyed but there isn't a fade. Here is the script:
local ting = 0 --debouncer
function onTouched(hit)
if ting == 0 then --debounce check ting = 1 --activate debounce check = hit.Parent:FindFirstChild("Humanoid") --Find the human that touched the button
if check ~= nil then --If a human is found, then
local user = game.Players:GetPlayerFromCharacter(hit.Parent) --get player from touching human local stats = user:findFirstChild("leaderstats") --Find moneyholder
if stats ~= nil then --If moneyholder exists then local cash = stats:findFirstChild("Money") --Get money cash.Value = cash.Value +200 --increase amount of money by the number displayed here (500) wait(1) --wait-time before button works again script.Parent.Transparency = 0.4 --Fade Part 1 script.Parent.Transparency = 0.8 --Fade Part 2 script.Parent:Destroy() --Fade Part 3 (Destroy) end
end
ting = 0 --remove debounce end end
script.Parent.Touched:connect(onTouched)
Any help would be appreciated. Thanks, Grilled |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Feb 2014 04:26 PM |
| You need to use wait() between each of the parts at which it changes Transparency. |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 01 Feb 2014 04:27 PM |
Please just trim it down to the error in the script. It gets you replies much faster.
script.Parent.Transparency = 0.4 --Fade Part 1 script.Parent.Transparency = 0.8 --Fade Part 2 script.Parent:Destroy() --Fade Part 3 (Destroy)
You have no waits, so the fade is faster than you can see it. |
|
|
| Report Abuse |
|
|
|
| 01 Feb 2014 04:31 PM |
Since that looks really choppy and the answer has been given to you, here's a generic loop that'll make the fade look very smooth.
for i = 1,20 do script.Parent.Transparency = script.Parent.Transparency + 0.05 wait() end script.Parent:Destroy()
You just replace this area:
"script.Parent.Transparency = 0.4 --Fade Part 1 script.Parent.Transparency = 0.8 --Fade Part 2 script.Parent:Destroy() --Fade Part 3 (Destroy)"
With what I gave you. |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 01 Feb 2014 04:35 PM |
| Yeah, go with rose. That is smoother. |
|
|
| Report Abuse |
|
|