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: Why does this only work in studio

Previous Thread :: Next Thread 
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
08 Jun 2015 11:18 PM
--Put this in a Gui Button

plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
pcall(function()
local Pos = plr.Character:GetPrimaryPartCFrame()
plr:LoadCharacter()
plr.Character:SetPrimaryPartCFrame(Pos)
if plr.Character:FindFirstChild("ForceField") then
plr.Character["ForceField"]:Destroy()
end
end)
end)
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
09 Jun 2015 11:05 AM
bump
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
09 Jun 2015 11:06 AM
LocalScript or ServerScript?

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
09 Jun 2015 11:07 AM
localscript in a gui button
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
09 Jun 2015 11:22 AM
This is really important 2 meh game
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
09 Jun 2015 11:34 AM
This on works but i really need the click gui to work.


Keywords = {":normal", ":refresh"}

game.Players.PlayerAdded:connect(function(plr)
plr.Chatted:connect(function(msg)
for _, v in pairs(Keywords) do
if v:lower() == msg:lower() then
pcall(function()
local Pos = plr.Character:GetPrimaryPartCFrame()
plr:LoadCharacter()
plr.Character:SetPrimaryPartCFrame(Pos)
if plr.Character:FindFirstChild("ForceField") then
plr.Character["ForceField"]:Destroy()
end
end)
end
end
end)
end)
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
09 Jun 2015 11:36 AM
add a wait() at the very top
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
09 Jun 2015 11:38 AM
still nothing

--Put this in a Gui Button

plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
wait()
pcall(function()
local Pos = plr.Character:GetPrimaryPartCFrame()
plr:LoadCharacter()
plr.Character:SetPrimaryPartCFrame(Pos)
if plr.Character:FindFirstChild("ForceField") then
plr.Character["ForceField"]:Destroy()
end
end)
end)
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
09 Jun 2015 11:50 AM
You can't use LoadCharacter in a LocalScript.
Report Abuse
SirIngenuity is not online. SirIngenuity
Joined: 06 Oct 2012
Total Posts: 3149
09 Jun 2015 12:27 PM
so what would you do to make this work
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
09 Jun 2015 01:15 PM
yes you can and op do you not understand what very top means i mean this is already a freemodel just work with me man put the wait() above plr
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
09 Jun 2015 01:24 PM
"yes you can"
No, you can't use LoadCharacter in a LocalScript. Read the wiki, test it yourself, do whatever, but I'm right on this one. This isn't the first time I've had someone argue that you can use it. You can't use it in a LocalScript!
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
09 Jun 2015 01:26 PM
Just use a RemoteEvent.

:FireServer() when you want to :LoadCharacter.

.OnServerEvent(player) when you want to receive it.

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
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