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 can I put a .Touched script in a local script?

Previous Thread :: Next Thread 
superpants2020 is not online. superpants2020
Joined: 10 Feb 2013
Total Posts: 804
20 Jan 2017 08:54 PM
Because I'm making a combat system and people are telling me you can't use .Touched in a local script... And I need it to play animations... So how do I do it?


nothing here.
Report Abuse
SPACEDUDZ is online. SPACEDUDZ
Joined: 12 Jul 2014
Total Posts: 257
20 Jan 2017 09:34 PM
The reason you cant just put a touch script in a local script is because if someone else touches the block, it will affect other players.

If you want to make it work with just a script then do this:

script.Parent.Touched:connect(function(Part)
Humanoid = Part.Parent:FindFirstChild("Humanoid")
if Humanoid ~= nil then
local animation=Instance.new("Animation",Part.Parent)
animation.Name="LocalAnimation"
animation.AnimationId="rbxassetid://Numbers"
anim=Humanoid:LoadAnimation(animation)
anim:Play()
end

This should work


Report Abuse
superpants2020 is not online. superpants2020
Joined: 10 Feb 2013
Total Posts: 804
20 Jan 2017 09:57 PM
so this would work in a local script?

if so thanks!


nothing here.
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