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: Works in studio but not in game...

Previous Thread :: Next Thread 
Hookyto is not online. Hookyto
Joined: 15 Jan 2010
Total Posts: 80
03 Apr 2017 06:11 AM
script.Parent.Lava.Touched:connect(function(hit)
if hit:FindFirstChild("Cash") then
local owner = game.Players.LocalPlayer
local cash = game.Players.LocalPlayer.leaderstats.Cash
if cash then
cash.Value = cash.Value + hit.Cash.Value
end
hit:Destroy()
end
end)


in game the dev console displays localplayer as a nil value...
Report Abuse
edenDeden is not online. edenDeden
Joined: 29 Jul 2016
Total Posts: 370
03 Apr 2017 06:31 AM
u cant only use local player in a local script





Report Abuse
edenDeden is not online. edenDeden
Joined: 29 Jul 2016
Total Posts: 370
03 Apr 2017 06:31 AM
can*


Report Abuse
Hookyto is not online. Hookyto
Joined: 15 Jan 2010
Total Posts: 80
03 Apr 2017 03:38 PM
bump
Report Abuse
Hookyto is not online. Hookyto
Joined: 15 Jan 2010
Total Posts: 80
03 Apr 2017 03:38 PM
then how would i? ive tried GetCharacterFromPlayer
Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
03 Apr 2017 03:39 PM
What are you attempting to do?.


#code print(string.rep("Lit",5))
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
03 Apr 2017 03:39 PM
"GetCharacterFromPlayer"

Umm...


Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
03 Apr 2017 03:39 PM
.Touched gets the character not the player.

so it would be looking for cash inside of the character model.
Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
03 Apr 2017 03:40 PM
Unsub is rigtht lol.


#code print(string.rep("Lit",5))
Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
03 Apr 2017 03:51 PM
script.Parent.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local money = player:FindFirstChild("leaderstats").money
if hit:IsA(player) then
money.Value = money.Value + 1



end
end)


#code print(string.rep("Lit",5))
Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
03 Apr 2017 03:51 PM
It doesnt invoke when a ### #### it so thats a bonus. #code print(string.rep("Lit",5))
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
03 Apr 2017 03:51 PM
no


Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
03 Apr 2017 03:56 PM
Woops
script.Parent.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local money = player:FindFirstChild("leaderstats").money
if hit.Parent:IsA(player) then
money.Value = money.Value + 1



end
end)


#code print(string.rep("Lit",5))
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
03 Apr 2017 03:57 PM
no and it'll still invoke regardless of what touches it, it's just a matter of the conditional statements evaluating to true


Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
03 Apr 2017 03:57 PM
True.


#code print(string.rep("Lit",5))
Report Abuse
Xstarlight is not online. Xstarlight
Joined: 18 Oct 2012
Total Posts: 870
03 Apr 2017 04:02 PM
Well, two things can happen.
1 You aren't using FE, so then use this:
#code script.Parent.Lava.Touched:connect(function(hit)
if hit.Parent.Humanoid and hit.Parent:FindFirstChild("Cash", true) then --the true in the findfirstchild function will make the function search in the childrens of the childrens of the childrens, etc until it reaches a matching name
local plr = game.Players:FindFirstChild(hit.Parent.Name)
local cash = plr.leaderstats.Cash
if cash then
cash.Value = cash.Value + hit.Cash.Value
end
hit:Destroy()
end
end)

Local Player can only be used for general things like mouse icon, etc.
For more specific things try what i showed you

2 You ARE using FE then:
Transfer the script to server-side, best way of saying it.


I would like to thank all my helpers in the forum, except you Tommy. I don't like Tommy...
Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
03 Apr 2017 04:03 PM
Lol?


#code print(string.rep("Lit",5))
Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
03 Apr 2017 04:03 PM
Do you even know what you're talking about lol?.


#code print(string.rep("Lit",5))
Report Abuse
Xstarlight is not online. Xstarlight
Joined: 18 Oct 2012
Total Posts: 870
03 Apr 2017 04:05 PM
I attempted, ######## Unlike you who just posts: "Lol" I would like to thank all my helpers in the forum, except you Quantum. I don't like Quantum...
Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
03 Apr 2017 04:05 PM
You're script is dumb lol honestly GetPlayerFromCharacter is so much easier and more efficent.


#code print(string.rep("Lit",5))
Report Abuse
Xstarlight is not online. Xstarlight
Joined: 18 Oct 2012
Total Posts: 870
03 Apr 2017 04:07 PM
Well, i'm sorry. I'm just trying to be helpful unlike you seems to just love messing with people.


I would like to thank all my helpers in the forum, except you Quantum. I don't like Quantum...
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
03 Apr 2017 04:07 PM
You guys are overcomplicating it...

OP, I don't know if `player` is supposed to already be defined. It looks like a tycoon to me.

local player -- define this somehow; owner of tycoon?
local cash = player.leaderstats.Cash -- no need to check; it's going to exist

script.Parent.Lava.Touched:Connect(function(part)
local value = part:FindFirstChild("Cash")
if value then
cash.Value = cash.Value + value.Value
end
end)


Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
03 Apr 2017 04:08 PM
You're misleading him because you dont even know what you're talking about so.


#code print(string.rep("Lit",5))
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
03 Apr 2017 04:08 PM
"no need to check; it's going to exist"

Assuming your game is FE like it should be.


Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
03 Apr 2017 04:08 PM
(I wasnt speaking to you unsub btw)


#code print(string.rep("Lit",5))
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