generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: This is frustrating... It refuses to work.

Previous Thread :: Next Thread 
jtefurd is not online. jtefurd
Joined: 01 May 2010
Total Posts: 952
30 May 2015 11:24 PM
Initially I made this all in a local gui, and I was told that you can't use the changed event in local guis. This was my solution and it ended up not working whatsoever. Background info:
- The local script cloning the client-side script is in a frame w/in starter gui.
- This script was meant for a red overlay when a player is hurt and it fades when the player nears full health.
-The client-sided script's parent is the local script.

Local Script:

cloned = script.Script:Clone()
cloned.Parent = game.Players.LocalPlayer.Character
cloned.Disabled = false

Client-Sided Script:

char = script.Parent
player = game.Players:GetPlayerFromCharacter(char)
MaxHealth = char.Humanoid.MaxHealth;Health = char.Humanoid.Health
char.Humanoid.Changed:connect(function()
if Health < MaxHealth then
player.PlayerGui.Health.BloodOverlay.BackgroundTransparency = 1-((.20*Health)/MaxHealth)
elseif Health == MaxHealth then
player.PlayerGui.Health.BloodOverlay.BackgroundTransparency = 1
end
end)
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
30 May 2015 11:24 PM
>>Initially I made this all in a local gui, and I was told that you can't use the changed event in local guis.

Whoever told you that is an idiot.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
30 May 2015 11:26 PM
I agree with nQqzRYVpIKA5jLP
Report Abuse
jtefurd is not online. jtefurd
Joined: 01 May 2010
Total Posts: 952
30 May 2015 11:26 PM
Crediting that information to ScriptingIntoTerror. XD
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
30 May 2015 11:27 PM
>>It refuses to work.
It's pretty impressive that you managed to create sentient life in only 10 lines of code.
Report Abuse
jtefurd is not online. jtefurd
Joined: 01 May 2010
Total Posts: 952
30 May 2015 11:30 PM
I'm only attempting to manipulate a gui's transparency with and equation based on a player's health. :\ It shouldn't have to be complicated.
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
30 May 2015 11:38 PM
You do realize that localscripts and client-sided scripts are the same thing, right? And why the hell do you have the health script in the character?
Report Abuse
jtefurd is not online. jtefurd
Joined: 01 May 2010
Total Posts: 952
30 May 2015 11:38 PM
He is my senpai so I trusted his decision, in the end however it still didn't work so yeah. :)
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
30 May 2015 11:46 PM
local player = game.Players.LocalPlayer
local char = player.Character
local human = char.Humanoid

human.Changed:connect(function()
if human.Health < human.MaxHealth then
script.Parent.BackgroundTransparency = 1-((0.20*human.Health)/human.MaxHealth)
elseif human.Health == human.MaxHealth then
script.Parent.BackgroundTransparency = 1
end
end)
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
30 May 2015 11:49 PM
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:wait()
local humanoid = character:WaitForChild("Humanoid")
local bloodOverlay = script.Parent:WaitForChild("BloodOverlay")

function updateGui(health)
bloodOverlay.BackgroundTransparency = health / humanoid.MaxHealth
end

humanoid.HealthChanged:connect(updateGui)
Report Abuse
jtefurd is not online. jtefurd
Joined: 01 May 2010
Total Posts: 952
31 May 2015 12:39 AM
At last I made it work. I had to fix the equation using a line equation XD y=.8x+.27
I also used HealthChanged, thanks everyone who helped!

local player = game.Players.LocalPlayer
local hum = player.Character:WaitForChild("Humanoid")
MaxHealth = hum.MaxHealth
hum.HealthChanged:connect(function(Health)
if Health < MaxHealth then
script.Parent.ImageTransparency = (.008*Health)+.27
elseif Health == MaxHealth then
script.Parent.ImageTransparency = 1
end
end)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image