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: This is like the 4th thing I'm putting here today(Help)

Previous Thread :: Next Thread 
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
23 Jun 2014 07:39 PM
Wow I'm becoming a regular, can't tell if this is good or bad.

function Clicked()
script.Parent.Parent.Parent.Character:MoveTo(game.Workspace.Part.Position)
end
script.Parent.MouseButton1Click:connect(onClicked)

This is going into my gui for each individual button, and I want it to spawn at random spots but I also don't want people to be able to spawn until they press a button help :)
Report Abuse
Vuva is not online. Vuva
Joined: 22 Jan 2010
Total Posts: 1102
23 Jun 2014 07:41 PM
The function names need to match:
"function Clicked()"
":connect(onClicked)"

either change the first one to "function onClicked" or change the second one to ":connect(Clicked)"
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
23 Jun 2014 07:41 PM
Try that.

function Clicked()
script.Parent.Parent.Parent.Character.Torso.CFrame = game.Workspace.Part.CFrame
end
script.Parent.MouseButton1Click:connect(onClicked)
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
23 Jun 2014 07:42 PM
If I were to change the blocks that it moves to with the name of 1 2 3 4 etc and put math.random(1,4)would that work for the spawning part of it?
Report Abuse
Vuva is not online. Vuva
Joined: 22 Jan 2010
Total Posts: 1102
23 Jun 2014 07:44 PM
Erm it would have to be a string.

If the parts' names were JUST numbers and they were in workspace you could do this:
:MoveTo(workspace[tostring(math.random(1,4))].Position)
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
23 Jun 2014 07:45 PM
You would do

function Clicked()
spawns = {"1","2","3","4"}
spawn = spawns[math.random(1,#spawns)]
actual = game.Workspace:findFirstChild(spawn)
script.Parent.Parent.Parent.Character.CFrame = actual.CFrame
end
script.Parent.MouseButton1Click:connect(Clicked)
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
23 Jun 2014 07:47 PM
Glacies did you just put the whole script there and complete the entire work I was working on for the past 45 minutes and did it in like a minute? Cause if so I LUB YOU <3 if not then I dont lub you but I dont hate you so its back to where it was before I knew you, thanks for helping though ^^
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
23 Jun 2014 07:49 PM
It didn't work glacies 20:48:46.283 - Character is not a valid member of ScreenGui
20:48:46.284 - Script 'Players.Player1.PlayerGui.Weapon Choose GUI.Main.Assault.Sc', Line 5
20:48:46.286 - Stack End
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
23 Jun 2014 08:28 PM
function Clicked()
spawns = {"1","2","3","4"}
spawn = spawns[math.random(1,#spawns)]
actual = game.Workspace:findFirstChild(spawn)
script.Parent.Parent.Parent.Parent.Character.CFrame = actual.CFrame
end
script.Parent.MouseButton1Click:connect(Clicked)



Mb there.



Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
23 Jun 2014 08:53 PM
Must be where?
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
25 Jun 2014 10:00 PM
Okay so my script is essentially supposed to sit inside my gui and when people select a class it is supposed to spawn them but it doesnt do anything at the moment which sucks. I want it to not have people spawn until they select their class so they don't complain about spawn kill.

Here is my gui script name "AssignClass"
player = script.Parent.Parent.Parent
backpack = player.Backpack

function chooseClass(class)
for i, v in pairs(backpack:GetChildren()) do v:remove() end
for i, v in pairs(class:GetChildren()) do
if v:IsA("Tool") then
v:clone().Parent = backpack
elseif v:IsA("HopperBin") then
v:clone().Parent = backpack
end
end

script.Parent.Main.Visible = false
script.Parent.Title.Visible = false
end

function onHumanoidDied(humanoid, player)
script.Parent.Main.Visible = true
script.Parent.Title.Visible = true
end

for i, v in pairs(script.Parent.Main:GetChildren()) do
v.MouseButton1Up:connect(function () chooseClass(v) end)
end

Here is my SpawnScript (That doesn't stop people from spawning or teleport them to a random spawn)

function OnClicked()
spawns = {"1","2","3","4"}
spawn = spawns[math.random(1,#spawns)]
actual = game.Workspace:findFirstChild(spawn)
game.Players.LocalPlayer.Character.Torso.CFrame = Workspace[math.random(4)]
end
script.Parent.Main.MouseButton1Up:connect(OnClicked)

And this is the message I get

22:17:20.954 - MouseButton1Up is not a valid member of Frame
22:17:20.955 - Script 'Players.Player1.PlayerGui.Weapon Choose GUI.LocalScript', Line 7
22:17:20.956 - Stack End
22:18:08.323 - Auto-Saving...

AFTER
I tried to fix it by changing the name of my frame buttons to mousebutton1up and now it says

22:47:53.414 - connect is not a valid member of TextButton
22:47:53.414 - Script 'Players.Player1.PlayerGui.Weapon Choose GUI.LocalScript', Line 7
22:47:53.415 - Stack End
22:48:08.661 - Auto-Saving...
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
26 Jun 2014 12:46 AM
Ayo I'm dumb and can't fix my issue cause im not an experience scripter, could I get some help.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
26 Jun 2014 12:51 AM
Simple. YOU CANT CLICK A FRAME.
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
26 Jun 2014 12:53 AM
Well technically all my buttons are scripted frames that are clickable so >.>
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
26 Jun 2014 12:57 AM
You cant click a frame. period.
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
26 Jun 2014 01:00 AM
Technically, you can it just wouldn't do anything, this site is technically a frame every pixel is a frame you can click it, it just has no function.
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
26 Jun 2014 01:01 AM
The idea is to give a function to my frame to keep people from spawning, and then when they click the frame it would spawn them randomly according to however many spawns are set up, since my maps are small I require this script due to the amount of spawn killing that happens.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
26 Jun 2014 01:01 AM
Lemme clarify
You cant attach a click event to a frame unless you use UDim2 functionalities, but if you're gonna do that, why not just use a ImageButton in the first place.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
26 Jun 2014 01:02 AM
And here's the fix

function OnClicked()
spawns = {"1","2","3","4"}
spawn = spawns[math.random(1,#spawns)]
actual = game.Workspace:findFirstChild(spawn)
game.Players.LocalPlayer.Character.Torso.CFrame = Workspace[math.random(4)]
end
script.Parent.Main.BUTTONNAME.MouseButton1Up:connect(OnClicked)
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
26 Jun 2014 01:04 AM
Hahaha, thanks you :)
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
26 Jun 2014 01:07 AM
The reason I wouldnt use an image button is because I want it to be set to classes, and the classes have names I'm not saying you have too but if you go into my game you would understand better :) :P
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
26 Jun 2014 01:22 AM
02:22:11.706 - Players.Player1.PlayerGui.Weapon Choose GUI.SpawnScript:8: bad argument #3 to 'CFrame' (CFrame expected, got userdata)
02:22:11.709 - Script 'Players.Player1.PlayerGui.Weapon Choose GUI.SpawnScript', Line 8
02:22:11.712 - Stack End
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
26 Jun 2014 01:41 AM
game.Players.LocalPlayer.Character.Torso.CFrame = Workspace[math.random(4)].CFrame
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
26 Jun 2014 01:44 AM
I feel like you should be more popular then you are >.> Thanks again
Report Abuse
tarrdo is not online. tarrdo
Joined: 24 Jun 2008
Total Posts: 476
26 Jun 2014 01:47 AM
Wazap I have one more thing, it does work to move the character to a random spot but it doesn't work to have them not spawn before pressing the button how would I add this into my script ?
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