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 » Scripting Helpers
Home Search
 

Re: ForceField onClick *HELP*

Previous Thread :: Next Thread 
cody20175 is not online. cody20175
Joined: 23 Jul 2010
Total Posts: 6958
06 Jun 2014 10:23 AM
So basically, it's a script that teleports you to the lobby if you click a button, and it gives you a forcefield.

plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
plr.Character.Torso.CFrame = CFrame.new(0,0,0)
Instance.new("ForceField", plr)
end)

The one to take away forcefield

plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
plr.Character.Torso.CFrame = CFrame.new(0,0,0)
plr:FindFirstChild:("ForceField"):Destroy() --i know this one's wrong, please help
end)



got hacked out of CF+ by horsdoeuvres
Report Abuse
Ultraw is not online. Ultraw
Joined: 20 Nov 2010
Total Posts: 6575
06 Jun 2014 10:26 AM
Doesn't look wrong to me
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
06 Jun 2014 10:27 AM
local player = game.Players.LocalPlayer
local character = player.Character
local forceField = false

function giveForceField()
if character then
Instance.new("ForceField", character)
end
end

function removeForceField()
if character and character:FindFirstChild("ForceField") then
character.ForceField:Destroy()
end
end

script.Parent.MouseButton1Click:connect(function()
if not forceField then
giveForceField()
else
removeForceField()
end)

Just so it's easy to break down and learn from.
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
06 Jun 2014 10:28 AM
You can add the teleports.
Report Abuse
cody20175 is not online. cody20175
Joined: 23 Jul 2010
Total Posts: 6958
06 Jun 2014 10:29 AM
um
You realize that's a non-working script right?


got hacked out of CF+ by horsdoeuvres
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
06 Jun 2014 10:29 AM
my script??
Report Abuse
cody20175 is not online. cody20175
Joined: 23 Jul 2010
Total Posts: 6958
06 Jun 2014 10:30 AM
oh @Ultraw

I haven't tried it yet, I was just about to, but I wanted opinions


got hacked out of CF+ by horsdoeuvres
Report Abuse
cody20175 is not online. cody20175
Joined: 23 Jul 2010
Total Posts: 6958
06 Jun 2014 10:30 AM
Yes @xx

The events, there are no functions, it would not work, the way it's set-up.
BRB testing it


got hacked out of CF+ by horsdoeuvres
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
06 Jun 2014 10:31 AM
Oops lol I just woke up, I'll fix it.
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
06 Jun 2014 10:32 AM
I forgot to change the bool value, silly mistake. The code should work.

local player = game.Players.LocalPlayer
local character = player.Character
local forceField = false

function giveForceField()
if character then
Instance.new("ForceField", character)
end
end

function removeForceField()
if character and character:FindFirstChild("ForceField") then
character.ForceField:Destroy()
end
end

script.Parent.MouseButton1Click:connect(function()
if not forceField then
giveForceField()
forceField = not forceField
else
removeForceField()
forceField = not forceField
end
end)
Report Abuse
cody20175 is not online. cody20175
Joined: 23 Jul 2010
Total Posts: 6958
06 Jun 2014 10:39 AM
plr = game.Players.LocalPlayer
char = plr.Character
script.Parent.MouseButton1Click:connect(function()
plr.Character.Torso.CFrame = CFrame.new(0,0,0)
Instance.new("ForceField", char)
end)

The one to take away forcefield

plr = game.Players.LocalPlayer
char = plr.Character
script.Parent.MouseButton1Click:connect(function()
plr.Character.Torso.CFrame = CFrame.new(0,0,0)
char:FindFirstChild:("ForceField"):Destroy() --i know this one's wrong, please help
end)


got hacked out of CF+ by horsdoeuvres
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
06 Jun 2014 10:39 AM
The code I posted is a fully functional forcefield giver/remover on click.
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
06 Jun 2014 10:41 AM
-- local player = game.Players.LocalPlayer
local character = player.Character
local forceField = false

function teleportToLobby()
if character then
character.Torso.CFrame = CFrame.new(0, 0, 0)
end
end

function teleportToBattle()
if character then
character.Torso.CFrame = CFrame.new(0, 0, 0)
end
end

function giveForceField()
if character then
Instance.new("ForceField", character)
end
end

function removeForceField()
if character and character:FindFirstChild("ForceField") then
character.ForceField:Destroy()
end
end

script.Parent.MouseButton1Click:connect(function()
if not forceField then
giveForceField()
teleportToLobby
forceField = not forceField
else
removeForceField()
teleportToBattle
forceField = not forceField
end
end)

cus u too lazy
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
06 Jun 2014 10:42 AM
err ma gud i commented the first line, undo that.
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
06 Jun 2014 10:43 AM
Ok I fully test this code and it works. I forgot the () on the functions.

local player = game.Players.LocalPlayer
local character = player.Character
local forceField = false

function teleportToLobby()
if character then
character.Torso.CFrame = CFrame.new(0, 0, 0)
end
end

function teleportToBattle()
if character then
character.Torso.CFrame = CFrame.new(0, 0, 0)
end
end

function giveForceField()
if character then
Instance.new("ForceField", character)
end
end

function removeForceField()
if character and character:FindFirstChild("ForceField") then
character.ForceField:Destroy()
end
end

script.Parent.MouseButton1Click:connect(function()
if not forceField then
giveForceField()
teleportToLobby()
forceField = not forceField
else
removeForceField()
teleportToBattle()
forceField = not forceField
end
end)
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
06 Jun 2014 10:54 AM
If he's using Filtering in his game, the force field will not replicate to the server.
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
06 Jun 2014 10:55 AM
Well I don't know a thing about this new fancy options and services.
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
06 Jun 2014 10:58 AM
FilteringEnabled makes it so that anything that you do on the client will not replicate over to the server without the use of RemoteFunctions/RemoteEvents.
Report Abuse
minminopop is not online. minminopop
Joined: 27 Apr 2012
Total Posts: 1030
06 Jun 2014 11:07 AM
Its great to stop exploitation.

But yeah,

http://wiki.roblox.com/index.php?title=Security
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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