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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Local Script can't find Character?

Previous Thread :: Next Thread 
Lightning0Splash is not online. Lightning0Splash
Joined: 20 Jun 2010
Total Posts: 1070
17 Apr 2015 06:02 PM
Everytime I would test the script ( it is in startergui as a local script ) it works perfectly. But if I go in the game, it says it can't find the Character. I tried making it into a varible, it now says it can't find the varible... here's the script

local power = 10
local p = false
local player = game.Players.LocalPlayer
local character = game.Players.LocalPlayer.Character
local mouse = player:GetMouse()
local bv = Instance.new("BodyVelocity")
bv.Parent = character.Torso
bv.maxForce = Vector3.new(0,0,0)
bv.velocity = Vector3.new(0,60,0)

mouse.KeyDown:connect(function(key)
if key:byte() == 32 and power > 2 then --spacebar is 32
p = true
bv.maxForce = Vector3.new(0,400000,0)
end
end)

mouse.KeyUp:connect(function(key)
if key:byte() == 32 then --spacebar is 32
p = false
bv.maxForce = Vector3.new(0,0,0)
end
end)

while wait(.1) do
print(power)
if power < 11 and p == false then
wait(.5)
power = power + 1
end
if p == true and power > 1 then
power = power - 1
--script.Parent.EBar.Size = script.Parent.EBar.Size - UDim2.new(0,0,0,2)
humanoid = game.Players.LocalPlayer.Character.Humanoid
elseif power < 1 then
player.Character.Torso.BodyVelocity.maxForce = Vector3.new(0,0,0)
end
end





anyone know the bug? :/
Report Abuse
Lightning0Splash is not online. Lightning0Splash
Joined: 20 Jun 2010
Total Posts: 1070
17 Apr 2015 06:13 PM
help. pls.
Report Abuse
MajikkuSoul is not online. MajikkuSoul
Joined: 15 Feb 2014
Total Posts: 196
17 Apr 2015 06:19 PM
I'm guessing wait until the character loads then do it? repeat wait() until game.Players.LocalPlayer.Character:findFirstChild('Torso')


~ All you need to know is that I'm an otaku
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
17 Apr 2015 06:40 PM
This is a better method

local character = player.Character or player.CharacterAdded:wait()

>This means if it finds a character, it will assign it as 'character', however if it doesn't, it will wait for the character to be added.
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
17 Apr 2015 06:42 PM
While I'm at it, I will revise your variables

local power, p = 10, false
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local mouse = player:GetMouse()
local bv = Instance.new('BodyVelocity', character:WaitForChild('Torso'))
bv.maxForce, bv.Velocity = Vector3.new(0,0,0), Vector3.new(0,60,0)
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
17 Apr 2015 07:07 PM
'local character = player.Character or player.CharacterAdded:wait()'

Good, good, good.
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