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
|
  |
| Joined: 13 Jun 2015 |
| Total Posts: 24 |
|
| |
|
thenimas
|
  |
| Joined: 13 Jun 2015 |
| Total Posts: 24 |
|
| |
|
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
|
  |
| 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
|
  |
| 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 |
|
|