|
| 30 Jun 2016 08:10 PM |
Since parts don't have a MouseButton1Click event or whatnot, this was supposed to be my way of geting around that by not letting a function fire unless the mouse was pressed down and then let go on the same target.
The mousebutton down function works flawlessly, and the mousebutton up function only half works. The section about the Plot and construction gui works perfectly, but during the upgrade section, well... nothing happens. No errors, no fired function
Idk what's wrong. The code looks fine to me. I can't make heads or tails of the problem I tried a print line just after the elseif statement but even that didnt print.
At this point, I am absolutely stuck. My game cannot be finished without this. It's part of the game's core function
local function CheckParent(Object) CurrentMouseSelection = nil if Object.Parent.Name:match("rbxl") then return end if Object.Parent.Name:match("Tower") and Object.Parent.Name ~= "Tower Base" then CurrentMouseSelection = Object.Parent else CheckParent(Object.Parent) end end
Mouse.Button1Down:connect(function(Object) if CCC == false then CCC = true if Mouse.Target ~= nil then if Mouse.Target.Name == "Plot" then CurrentMouseSelection = Mouse.Target print(CurrentMouseSelection) elseif Mouse.Target:IsA("BasePart") then CheckParent(Mouse.Target) print(CurrentMouseSelection) end end end end)
Mouse.Button1Up:connect(function() if CCC == true then if Mouse.Target ~= nil then if Mouse.Target == CurrentMouseSelection then if Mouse.Target.Name == "Plot" then if Mouse.Target.Transparency == 0 then if MUI:findFirstChild("Construction") then MUI.Construction:Destroy() end if MUI:findFirstChild("Upgrader") then MUI.Upgrader:Destroy() end PrepareConctructionGui(MUI, Mouse, CurrentMouseSelection) end elseif Mouse.Target:IsDescendantOf(CurrentMouseSelection) then if MUI:findFirstChild("Construction") then MUI.Construction:Destroy() end if MUI:findFirstChild("Upgrader") then MUI.Upgrader:Destroy() end PrepareUpgradeGui(MUI, CurrentMouseSelection) end end end CCC = false end end) |
|
|
| Report Abuse |
|
|
| |
|
daireb
|
  |
| Joined: 16 Nov 2012 |
| Total Posts: 726 |
|
|
| 01 Jul 2016 09:18 AM |
This should be in scripters. And, why aren't you using a mousedetector in the part? |
|
|
| Report Abuse |
|
|
|
| 01 Jul 2016 09:33 AM |
Because it doesn't work that way. I'd still have to use the check function to make sure the part's ancestor was a tower. I had this conversation with someone already.
And no, this is supposed to be here. I'll say it again,
Scripters Forum This is the place for discussion about scripting. Anything about scripting that is not a help request or topic belongs here.
And also roblox had already officially stated that when they removed the old scripting helpers and building helpers forums that we were meant to post them here in Game Design from now on.
Why do I keep having to have this conversation over and over? I need help with that thing up above, not arguing about where it's supposed to be posted |
|
|
| Report Abuse |
|
|
|
| 01 Jul 2016 09:37 AM |
Look, I don't like asking for help. It puts me in very awkward situations. Sometimes I have an argument, sometimes people help me. Either way I die a little inside knowing I wasn't smart enough to fix the problem myself.
So can you PLEASE just help...? |
|
|
| Report Abuse |
|
|
|
| 01 Jul 2016 11:28 AM |
| The CheckParent function works just fine. It sets the tower as the CurrentMouseSelection like it should, so when the mouse button is let go while still being on the same target, the elseif line should fire, but it's like it doesn't recognize it anymore. I don't know how to fix this one |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
greenmaxy
|
  |
| Joined: 15 Jun 2012 |
| Total Posts: 330 |
|
|
| 02 Jul 2016 10:14 AM |
| Mouse is supposed to be mouse. No capital m. |
|
|
| Report Abuse |
|
|
greenmaxy
|
  |
| Joined: 15 Jun 2012 |
| Total Posts: 330 |
|
|
| 02 Jul 2016 10:15 AM |
| Never mind i dno't think that's the issue |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2016 11:07 AM |
I can't post the whole script though. I got an error saying it was too long. I did define it as Mouse up at the top of the script, though. If someone were willing to help, I wouldn't mind putting it on codepad or something |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2016 11:10 AM |
qQkXZPEC
Here, I put it on codepad. I know it's not the most efficient script, but I have a learning disability. After 8 years of roblox, this is literally the best I can do |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2016 11:12 AM |
| omfg it didn't even paste the whole thing into codepad |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2016 11:14 AM |
There, the first and second half on codepad. Even codepad can't hold all of the lines :/
qQkXZPEC
DCrviusm |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Jul 2016 01:38 PM |
Use a click detector.
Also, while the scripters forum might be described like that on the roblox site, help request actually DO go in there, even if roblox says otherwise. Just go have a gander and you'll see that 95% of the posts in there are help requests.
|
|
|
| Report Abuse |
|
|
|
| 02 Jul 2016 06:09 PM |
| turned out I placed an end after the elseif condition in Button1Up when it should have come before |
|
|
| Report Abuse |
|
|