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: Giver help is still needed

Previous Thread :: Next Thread 
thenimas is not online. thenimas
Joined: 13 Jun 2015
Total Posts: 24
25 Nov 2015 08:16 PM
This script is contained in a ball. It is cloned from a folder in lighting called Balls. There are two kinds of balls, and each ball is to be placed in a random area at position y 100, in work space. There is another folder called Items in lighting which has a bunch of gear inside.

---------------------------------------------------------------------------------

local humanoid = script.Parent.Parent:findFirstChild("Humanoid")
local items = game.Lighting.PickUpItems:GetChildren()
local clone = items[math.random(1, #items)]:clone()

function onTouched(part)
print "Part Touched"
if (humanoid~=nil) then
local thisplr = game.Players:findFirstChild(humanoid.Parent.Name)
print "Humanoid Detected"
if (thisplr~=nil) then
print "Person Profile Found"
clone.Parent = thisplr.Backpack
script.Parent:remove()
end
end
end

script.Parent.Touched:connect(onTouched)

---------------------------------------------------------------------------------

Script is intended to: Award the player with a random item when the ball is touched, then it will delete itself.

Script instead: Says "Part Touched" in the output when it falls onto the baseplate, and nothing else happens when a player touches it.
Report Abuse
thenimas is not online. thenimas
Joined: 13 Jun 2015
Total Posts: 24
25 Nov 2015 08:35 PM
bump
Report Abuse
thenimas is not online. thenimas
Joined: 13 Jun 2015
Total Posts: 24
25 Nov 2015 08:49 PM
bump
Report Abuse
Ben1925 is not online. Ben1925
Joined: 07 Apr 2011
Total Posts: 741
25 Nov 2015 08:53 PM
You can simplify "if humanoid~=nil". You're basically saying here that "if humanoid is not nil." You can already say "if humanoid" which means exactly the same thing, "if humanoid exists"
Report Abuse
thenimas is not online. thenimas
Joined: 13 Jun 2015
Total Posts: 24
26 Nov 2015 01:04 PM
Okay, I'll try it soon, but I doubt it'll exactly help
Report Abuse
Ben1925 is not online. Ben1925
Joined: 07 Apr 2011
Total Posts: 741
28 Nov 2015 05:22 PM
The script is intended to award the player that touches it with an item, yes?


local humanoid = script.Parent.Parent:findFirstChild("Humanoid") -- Then why do you define this early? Shouldn't you only be defining this once the ball has been touched?

-- The script should be more like this:


local items = game.Lighting.PickUpItems:GetChildren()
local clone = items[math.random(1, #items)]:clone()

function onTouched(part)
print "Part Touched"
if part.Parent and part.Parent:IsA("Model") then
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid then
local character = game.Players:FindFirstChild(humanoid.Parent.Name)
print "Humanoid Detected"
if character then
print "Person Profile Found"
clone.Parent = game:GetService('Players'):GetPlayerFromCharacter(character).Backpack
script.Parent:remove()
end
end
end

script.Parent.Touched:connect(onTouched)
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