|
| 21 May 2016 09:04 PM |
Ho would I clone a script that is inside of workspace into the character instead of backpack?
I have this currently:
game.Workspace.sprint.SprintScript:Clone().Parent = game.Players.LocalPlayer.Character |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 21 May 2016 09:07 PM |
You can put the script in StarterPlayer>StarterCharacterScripts instead of cloning it :)
|
|
|
| Report Abuse |
|
|
|
| 21 May 2016 09:08 PM |
| Well, I'm actually removing it from their character first and then, when they press a button, they get the script again. |
|
|
| Report Abuse |
|
|
fang
|
  |
| Joined: 20 Mar 2007 |
| Total Posts: 88 |
|
|
| 21 May 2016 09:09 PM |
| clone it into their playergui |
|
|
| Report Abuse |
|
|
|
| 21 May 2016 09:10 PM |
| It's not a playergui either. It's a sprint with a keyevent. When they press shift it makes them go faster. I can easily remove it, but cloning it back into the player script is tricky for me. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 21 May 2016 09:10 PM |
Seems unsound.
Though, to do it your way, you would need to somehow define the character. You say they press a button? Post that code below.
|
|
|
| Report Abuse |
|
|
fang
|
  |
| Joined: 20 Mar 2007 |
| Total Posts: 88 |
|
|
| 21 May 2016 09:16 PM |
repeat wait() until game.Players.LocalPlayer.Character
local clone = game.Workspace.sprint.SprintScript:Clone()
clone.Parent = game.Players.LocalPlayer.Character |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 21 May 2016 09:17 PM |
^ I'm willing to bet this is not being done in a Local Script
|
|
|
| Report Abuse |
|
|
|
| 21 May 2016 09:18 PM |
This is where the deletion of the script occurs and the clone
game.Players.LocalPlayer.Character.SprintScript:Destroy() elseif JinActive == true then print("Jin Cloak Expired!") script.Parent.Parent.Character.Head.face.Face = "Front" game:GetService("Chat"):Chat(player.Character.Head, "Oh Nou.") JinActive = false script.Parent.Parent.Character.Humanoid.WalkSpeed = 16 game.Players.LocalPlayer.Character.Shirt.ShirtTemplate = script.ShirtValue.Value game.Players.LocalPlayer.Character.Pants.PantsTemplate = script.PantsValue.Value t1:Destroy() t2:Destroy() t3:Destroy() t4:Destroy() t5:Destroy() t6:Destroy() game.Players.LocalPlayer.Backpack.FlyingScript:Destroy() game.Players.LocalPlayer.Backpack.RasenShuriken:Destroy() game.Players.LocalPlayer.Backpack.StickSword:Destroy() game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 100 game.Players.LocalPlayer.Character.Humanoid.Health = 75 game.Players.LocalPlayer.Character.Animate.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=125749145" game.Players.LocalPlayer.Character.Animate.idle.Animation1.AnimationId = "rbxassetid://125750618" game.Workspace.sprint.SprintScript:Clone().Parent = Character |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 21 May 2016 09:19 PM |
Wow you were right, it is being done in a local script.
Just change the last line to
game.Workspace.sprint.SprintScript:Clone().Parent = game.Players.LocalPlayer.Character
|
|
|
| Report Abuse |
|
|
fang
|
  |
| Joined: 20 Mar 2007 |
| Total Posts: 88 |
|
|
| 21 May 2016 09:20 PM |
yea lol u didnt define Character anywhere rip |
|
|
| Report Abuse |
|
|
|
| 21 May 2016 09:21 PM |
Okay, so when someone enters the game, they get the sprint.
They press 'J' to transform, which removes the script.
They press 'J' again which takes away the transformation and adds the sprint again.
The transformation script is currently is starterpack(it's going to be removed eventually to clone into the charatcers backpack.) and it's a local script. |
|
|
| Report Abuse |
|
|
|
| 21 May 2016 09:22 PM |
| Soybean, that's literally what i want in my first post, and like I said before, that didn't work. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 21 May 2016 09:24 PM |
Well you're trying to manipulate server-side objects from a Local Script The only reason I think you can delete Sprint in the first place is because you can manipulate your Character locally (to some degree), but I'd wager it's a different story trying to clone it from the workspace and slap it into the character when everything's already in motion.
Use a regular script instead, and find some other way to identify the character.
|
|
|
| Report Abuse |
|
|
|
| 21 May 2016 09:28 PM |
sprint.ScriptSprint
sprint is a script that makes it go to the character
ScriptSprint is a local script. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 21 May 2016 09:30 PM |
You can't define LocalPlayer from a Server Script.
|
|
|
| Report Abuse |
|
|
|
| 21 May 2016 09:32 PM |
this is the script that makes scriptsprint go into the character
function onPlayerEntered(player) repeat wait () until player.Character ~= nil local s = script.SprintScript:clone() s.Parent = player.Character s.Disabled = false player.CharacterAdded:connect(function (char) local s = script.SprintScript:clone() s.Parent = char s.Disabled = false end) end
game.Players.PlayerAdded:connect(onPlayerEntered) |
|
|
| Report Abuse |
|
|
|
| 21 May 2016 09:33 PM |
| So I can't clone an item in workspace to the character from a localscript? |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 21 May 2016 09:36 PM |
You can, I'm just having a hard time wrapping my head around all these different scripts you've got going.
|
|
|
| Report Abuse |
|
|
|
| 21 May 2016 09:39 PM |
It's really simple tho.
When you enter the game the sprint script works. Hold shift and walk and it works.
Press 'j' and transform and it works. The script is removed.
Press 'j' again and the sprint script isn't placed back in your character. Everything works except the cloning of the script. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 21 May 2016 09:42 PM |
It might be a really simple idea, but your execution is all over the place. X)
|
|
|
| Report Abuse |
|
|
|
| 21 May 2016 09:49 PM |
| I found a way to do it, and it works in testing, but not in actual play? |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 21 May 2016 09:52 PM |
Then that's an issue between Local & Server scripts
Because YOU are the server in playtest (sort of), Local Scripts are able to do weird things, like communicate back and forth with the server - because the client and server are smashed into one.
|
|
|
| Report Abuse |
|
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 21 May 2016 09:58 PM |
Haha, I recommend starting fresh. You have so much going on, it's often just better to drop it and approach it another way.
|
|
|
| Report Abuse |
|
|