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: How do I do this?

Previous Thread :: Next Thread 
LuckyScaryBookworms is not online. LuckyScaryBookworms
Joined: 26 Feb 2012
Total Posts: 206
20 Nov 2017 04:27 PM
I have a script where If a tool hits a block X times then it will give the player the item.

However, its multiplayer. How Would I determine the owner of the tool.


How would I set it up after this:
...
if if hit.Parent.Name == "RustyPicax"
???????
...

-How can I determine the owner of the tool?
-Each player gets the same tool.
Report Abuse
LuckyScaryBookworms is not online. LuckyScaryBookworms
Joined: 26 Feb 2012
Total Posts: 206
20 Nov 2017 05:06 PM
Anyone?
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
20 Nov 2017 05:13 PM
Is it a physical hit you are talking about? Like bumping the handle of the tool against the block?

script.Parent.Touched:connect(function(hit)
if (hit.Parent) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
if (player) then
--[[Whatever you want to do, the player variable is the player whose tool hit the block.]]
end
end
return (nil);
end)
Report Abuse
LuckyScaryBookworms is not online. LuckyScaryBookworms
Joined: 26 Feb 2012
Total Posts: 206
20 Nov 2017 05:13 PM
Here is the full script:
How do I make it give the UnrefinedIronOre to the player that owns the picax?
I put a value in picax called "Owner" and set it to change to the localplayer; however, I am still unsure how to give the player the ore.
hits = script.Parent.hits.Value
hitsneeded = script.Parent.hitsneeded.Value
Ore = game.ReplicatedStorage.UnrefinedIronOre
local Reciever = ?????????????????????
-------------------------------------
function Reset()
script.Parent.CanCollide = true
script.Parent.Transparency = 0
hits = 0
end
------------------------------------
function MineIronOre()
script.Parent.CanCollide = false
script.Parent.Transparency = 1
print "IronOreMined"
end
-------------------------------------
function onTouch(hit)
if hit.Parent.Name == "RustyPicax" then
hits = hits+1
script.Parent.Mine:Play()
wait(0.5)
else ---Coming Soon---Picaxe/Drill levels.
end
if hits > hitsneeded then
MineIronOre()
wait(5)Reset()


end
end

script.Parent.Touched:connect(onTouch)
Report Abuse
LuckyScaryBookworms is not online. LuckyScaryBookworms
Joined: 26 Feb 2012
Total Posts: 206
20 Nov 2017 05:15 PM
Yes 128Gigabytes. I will try your idea.
Report Abuse
LuckyScaryBookworms is not online. LuckyScaryBookworms
Joined: 26 Feb 2012
Total Posts: 206
20 Nov 2017 05:31 PM
Do I implement it like this, or do I just copy exactly what you did?

I added:local PersonThatGetsOre = game.PlayerFromCharacter(hit.Parent.Parent) and
Ore.Parent = PersonThatGetsOre.Backpack

Nothing happened? Do I have to define hit or something?
----------------------------------------------------------------

hits = script.Parent.hits.Value
hitsneeded = script.Parent.hitsneeded.Value
local Ore = game.ReplicatedStorage.UnrefinedIronOre:Clone()
local PersonThatGetsOre = game.PlayerFromCharacter(hit.Parent.Parent)
-------------------------------------
function Reset()
script.Parent.CanCollide = true
script.Parent.Transparency = 0
hits = 0
end
------------------------------------
function MineIronOre()
script.Parent.CanCollide = false
script.Parent.Transparency = 1
print "IronOreMined"

Ore.Parent = PersonThatGetsOre.Backpack
end
--------------------------------------------------------------------------
function onTouch(hit)
if hit.Parent.Name == "RustyPicax" then
hits = hits+1
script.Parent.Mine:Play()
wait(0.5)
else ---Coming Soon---Picaxe/Drill levels.
end

if hits > hitsneeded then
MineIronOre()
wait(5)Reset()


end
end

script.Parent.Touched:connect(onTouch)
Report Abuse
LuckyScaryBookworms is not online. LuckyScaryBookworms
Joined: 26 Feb 2012
Total Posts: 206
20 Nov 2017 07:35 PM
Bump. If you don’t want to spend time on this could someone link a tutorial or free model to look off of?
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
20 Nov 2017 09:46 PM
Is this script inside the block or the tool itself? I'm assuming blocking, and that isn't how you should be doing it.

But if you wanna keep doing it that way you implemented my suggestion incorrectly, it needs to go inside the onTouch function you created not at the top of your script.
Report Abuse
LuckyScaryBookworms is not online. LuckyScaryBookworms
Joined: 26 Feb 2012
Total Posts: 206
21 Nov 2017 05:58 AM
The script is inside the block. When any block named “RustyPicax” touches the block I want it to give the ore the player. My problem is that every player owns the same tool. I needed to add a script that determines the owner of the tool that hit it. I will try your idea soon.
Report Abuse
LuckyScaryBookworms is not online. LuckyScaryBookworms
Joined: 26 Feb 2012
Total Posts: 206
21 Nov 2017 06:03 AM
Ok so like this?
hits = script.Parent.hits.Value
hitsneeded = script.Parent.hitsneeded.Value
local Ore = game.ReplicatedStorage.UnrefinedIronOre:Clone()

-------------------------------------
function Reset()
script.Parent.CanCollide = true
sc########################## #
# hits = 0
end
------------------------------------
function MineIronOre()
script.Parent.CanCollide = false
script.Parent.Transparency = 1
print "IronOreMined"

end
--------------------------------------------------------------------------
function onTouch(hit)
script.Parent.Touched:connect(function(hit)
if (hit.Parent) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
if (player) then
if hit.Parent.Name == "RustyPicax" then
hits = hits+1
script.Parent.Mine:Play()
wait(0.5)
else ---Coming Soon---Picaxe/Drill levels.
end
end
return (nil);
end)


if hits > hitsneeded then
MineIronOre()
wait(5)Reset()


end
end

script.Parent.Touched:connect(onTouch)
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
21 Nov 2017 08:42 PM
Put this inside the tool


script.Parent.Handled.Touched:connect(function(basePart)
if (basePart.Name == "gold ore") then --[[Change to whatever you named it.]]
local player = game.Players:FindFirstChild(script.Parent.Parent.Name)
if (player) then
basePart:Destroy()
player.leaderstats.Gold.Value = (player.leaderstats.Gold.Value + 5)
end
end
return (nil);
end
Report Abuse
LuckyScaryBookworms is not online. LuckyScaryBookworms
Joined: 26 Feb 2012
Total Posts: 206
22 Nov 2017 08:52 AM
How would I define the IronOre that the tool touched?
Is it already defined as basepart?

Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
22 Nov 2017 04:09 PM
Yes
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