redditing Posted February 28, 2020 Share Posted February 28, 2020 function building(key, state) local x, y, z = getElementPosition(getLocalPlayer()) local build = createObject(3374, x, y, z, 0, 0, 0) setElementAlpha(build, 150) attachElements(build, localPlayer , 0, 3, -1, 0, 0, 0) if key=="b" and state=="up" then if isElementAttached(build) then setElementAlpha(build, 255) detachElements(build, getLocalPlayer()) end end end bindKey("b", "both", building) When I release B, he puts a block of hay for me, but I don't lose the stick which stuck to me, PLS HELP Link to comment
Developer. Posted February 28, 2020 Share Posted February 28, 2020 (edited) local player = getLocalPlayer(); local build function building(key, state) if (key == "b") then -- check Key pressed if (state == "down") then -- check state destroy(build) -- useful local x, y, z = getElementPosition(player); build = createObject(3374, x, y, z, 0, 0, 0); setElementAlpha(build, 150); attachElements(build, player , 0, 3, -1, 0, 0, 0); elseif (state =="up") then -- check state if isElementAttached(build) then setElementAlpha(build, 255); detachElements(build, player); setTimer(function() destroy(build) end, 1500, 1); end end end end bindKey("b", "both", building) function destroy(element) -- useful function if isElement(element) then -- if exists destroyElement(element) -- destroy end end Edited February 28, 2020 by Developer. I forgot some things Link to comment
Moderators Patrick Posted February 28, 2020 Moderators Share Posted February 28, 2020 (edited) Because first time, when you press it down, the function stops in line 6, and leave. Second time, when you release the button, it starts from the beginning, again. (create again the object) But then, it not stop in line 6, and immediately deatach the new object. And old object is still attached to you. Edited February 28, 2020 by Patrick Link to comment
redditing Posted February 28, 2020 Author Share Posted February 28, 2020 22 hours ago, Patrick said: Because first time, when you press it down, the function stops in line 6, and leave. Second time, when you release the button, it starts from the beginning, again. (create again the object) But then, it not stop in line 6, and immediately deatach the new object. And old object is still attached to you. I love u man Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now