I wanted List of roblox players in ScrollingFrame, every player is in this list is a button, and when i click any player, his name Appears in Target box
Script:
for i, v in pairs(game.Players:GetChildren()) do ---gets players in list [PlayersList is a ScrollingFrame] when i join game
thc = i/25
local Player = Instance.new("TextButton")
Player.Name = v.Name
Player.Parent = PlayersList
Player.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
Player.BackgroundTransparency = 0.800
Player.Position = UDim2.new(-0.00711364765, 0, thc, 0)
Player.Size = UDim2.new(0, 100, 0, 30)
Player.Font = Enum.Font.FredokaOne
Player.Text = v.Name
Player.TextColor3 = Color3.fromRGB(255, 255, 255)
Player.TextScaled = true
Player.TextSize = 14.000
Player.TextWrapped = true
end
local plr = game.Players.LocalPlayer
game.Players.PlayerAdded:Connect(function(jplr) ---Adds new player in list
print(jplr, 'joined')
for a, b in pairs(PlayersList:GetChildren()) do
b:Destroy()
end
for i, v in pairs(game.Players:GetChildren()) do
thc = i/25
local Player = Instance.new("TextButton")
Player.Name = v.Name
Player.Parent = PlayersList
Player.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
Player.BackgroundTransparency = 0.800
Player.Position = UDim2.new(-0.00711364765, 0, thc, 0)
Player.Size = UDim2.new(0, 100, 0, 30)
Player.Font = Enum.Font.FredokaOne
Player.Text = v.Name
Player.TextColor3 = Color3.fromRGB(255, 255, 255)
Player.TextScaled = true
Player.TextSize = 14.000
Player.TextWrapped = true
end
end)
game.Players.PlayerRemoving:Connect(function(lplr) ---Remove's Players which leave the game
print(lplr, 'left')
for a, b in pairs(PlayersList:GetChildren()) do
b:Destroy()
end
for i, v in pairs(game.Players:GetChildren()) do
if v.Name ~= lplr.Name then
thc = i/25
local Player = Instance.new("TextButton")
Player.Name = v.Name
Player.Parent = PlayersList
Player.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
Player.BackgroundTransparency = 0.800
Player.Position = UDim2.new(-0.00711364765, 0, thc, 0)
Player.Size = UDim2.new(0, 100, 0, 30)
Player.Font = Enum.Font.FredokaOne
Player.Text = v.Name
Player.TextColor3 = Color3.fromRGB(255, 255, 255)
Player.TextScaled = true
Player.TextSize = 14.000
Player.TextWrapped = true
end
end
end)
for g, n in pairs(PlayersList:GetChildren()) do
local ind = n.Text
PlayersList[n.Text]:Connect(function()
TargBox.Text = n.Name
end)
end
Output: Connect is not a valid member of TextButton "Players.Artemka_KRYT.PlayerGui.PrisonByGhosty.MenuButton.BackGround.Taravatar.TargBox.PlayersList.Artemka_KRYT"
You need to connect to an event on the TextButton, not the button itself. I would recommend the Activated event as it fires when someone clicks on the button, and it works on mobile too.
for g, n in pairs(PlayersList:GetChildren()) do
local ind = n.Text
local btn = PlayersList[ind]
btn.Activated:Connect(function()
TargBox.Text = n.Name
end)
end
Related
I tried creating a label with an offset and having the alert trigger from the label displayed on the chart but I'm stuck at this point
prd = input.int(defval=10, title='Pivot Period', minval=4, maxval=30, group='Setup')
float src1 = ppsrc == 'High/Low' ? high : math.max(close, open)
float src2 = ppsrc == 'High/Low' ? low : math.min(close, open)
float ph = ta.pivothigh(src1, prd, prd)
float pl = ta.pivotlow(src2, prd, prd)
plotshape(ph and src1, style=shape.triangledown, text='SELL(H)', color=na, textcolor=color.new(#eeff00, 0), location=location.abovebar, offset=-prd)
plotshape(pl and src2, style=shape.triangleup, text='BUY(L)', color=na, textcolor=color.new(#ffffff, 0), location=location.belowbar, offset=-prd)
Lstyle = linestyle == 'Dashed' ? line.style_dashed : linestyle == 'Solid' ? line.style_solid : line.style_dotted
labeloffset = prd
labelcolor = color.red
labeltext = "Sell(R)"
labelcolor2 = color.green
labeltext2 = "Buy(S)"
value1 = ph and src1
value2 = pl and src2
var label ourlabel = na
label_ph = label.new(x = bar_index - labeloffset, y = na, text = labeltext, color = labelcolor, xloc = xloc.bar_index, yloc = yloc.abovebar, textcolor = color.white, style = label.style_label_down, size = size.normal, tooltip = "pl_label_id")
label_pl = label.new(x = bar_index - labeloffset, y = na, text = labeltext2, color = labelcolor2, xloc = xloc.bar_index, yloc = yloc.belowbar, textcolor = color.white, style = label.style_label_up, size = size.normal, tooltip = "ph_label_id")
// Defined my conditions for the label
if ph and src1
label_ph
else
label.delete(ourlabel)
if pl and src2
label_pl
else
label.delete(ourlabel)
My_Theme <- theme(axis.title.x = element_text(size = 24),axis.text.x =
element_text(size = 20),axis.text.y = element_text(size = 20),axis.title.y = element_text(size = 24),plot.title = element_text(size = 25))
tt <- fviz_screeplot(t3.mfa, choice = "variance", barfill = "white",
barcolor="steelblue",linecolor="red", ncp = 16, addlabels = TRUE, hjust = 0, main = NULL,
xlab = NULL, ylab = NULL)
mytt <- tt + My_Theme + theme(plot.title = element_text(hjust = 0.5))
myttt <- mytt + labs(title = "Variances - MFA", x = "Principal Components", y = "% of variances")
myttt + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank())
This code does not have an error when running on a computer, but when I move all the files and run it on a Raspberry Pi, I get this error. Where and how to fix it?
OSError; savedModel file does not exist at: models/mask_detector.model/{saved_model.pbtxt|saved_model.pb}
from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
from tensorflow.keras.models import load_model
import numpy as np
import cv2
facenet = cv2.dnn.readNet('models/deploy.prototxt', 'models/res10_300x300_ssd_iter_140000.caffemodel')
model = load_model('models/mask_detector.model')
cap = cv2.VideoCapture(0)
i = 0
while cap.isOpened():
ret, img = cap.read()
if not ret:
break
h, w = img.shape[:2]
blob = cv2.dnn.blobFromImage(img, scalefactor=1., size=(300, 300), mean=(104., 177., 123.))
facenet.setInput(blob)
dets = facenet.forward()
result_img = img.copy()
for i in range(dets.shape[2]):
confidence = dets[0, 0, i, 2]
if confidence < 0.5:
continue
x1 = int(dets[0, 0, i, 3] * w)
y1 = int(dets[0, 0, i, 4] * h)
x2 = int(dets[0, 0, i, 5] * w)
y2 = int(dets[0, 0, i, 6] * h)
face = img[y1:y2, x1:x2]
face_input = cv2.resize(face, dsize=(224, 224))
face_input = cv2.cvtColor(face_input, cv2.COLOR_BGR2RGB)
face_input = preprocess_input(face_input)
face_input = np.expand_dims(face_input, axis=0)
mask, nomask = model.predict(face_input).squeeze()
if mask > nomask:
color = (0, 255, 0)
label = 'Mask %d%%' % (mask * 100)
else:
color = (0, 0, 255)
label = 'No Mask %d%%' % (nomask * 100)
cv2.rectangle(result_img, pt1=(x1, y1), pt2=(x2, y2), thickness=2, color=color, lineType=cv2.LINE_AA)
cv2.putText(result_img, text=label, org=(x1, y1 - 10), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=0.8,
color=color, thickness=2, lineType=cv2.LINE_AA)
cv2.imshow('img',result_img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
I am trying to create a game with Corona, but I can't figure out how to make swipe controls. I want to make a character that can move along x, -x, y, -y depending on which direction you swipe. any advice is needed because I'm lost. This code currently uses buttons to move the player when the button is press the player moves in that direction. I would like to change the button press to a swipe. The move events are at the bottom, and the button press events are in the middle.
local backdrop = display.setDefault("background", 1, 1, 1)
local physics = require("physics")
physics.start()
local square = display.newRect( 0, 0, 5, 5 )
--print(square)
_W = display.contentWidth; -- Get the width of the screen
_H = display.contentHeight; -- Get the height of the screen
motionDown = 0;
motionUp = 0;
motionRight = 0;
motionLeft = 0;
motionSquare = 5
speed = 4
local left = display.newRect(0,0,_W/2,_H/1.19)
left.x = _W/4.5; left.y = _H/2;
local right = display.newRect(0,0,_W/2,_H/1.19)
right.x = _W/1.25; right.y = _H/2;
local top = display.newRect(0,0,_W,_H/5.5)
top.x = _W/2; top.y =0;
local bottem = display.newRect(0,0,_W,_H/5.5)
bottem.x = _W/2; bottem.y =_H;
player = display.newImage("player.png", display.contentCenterX, display.contentCenterY)
player.x = math.random(10,_W-10)
player.y = math.random(10,_H-10)
player:toFront(player)
physics.addBody( player, "static" )
function left:tap() --Left
motionDown = 0;
motionUp = 0;
motionRight = 0;
motionLeft = -speed;
local square = display.newRect( 0, 0, 5, 5 )
square.strokeWidth = 3
square:setFillColor( 0 )
square:setStrokeColor( 0, 0, 0 )
square.x = player.x + 10 ; square.y = player.y;
local function moveSquare (event)
square.x = square.x + motionSquare;
end
Runtime:addEventListener("enterFrame", moveSquare)
return square
end
left:addEventListener("tap",left)
square = left:tap()
function right:tap() --Right
motionDown = 0;
motionUp = 0;
motionLeft = 0;
motionRight = speed;
local square = display.newRect( 0, 0, 5, 5 )
square.strokeWidth = 3
square:setFillColor( 0 )
square:setStrokeColor( 0, 0, 0 )
square.x = player.x - 10 ; square.y = player.y;
local function moveSquare (event)
square.x = square.x - motionSquare;
end
Runtime:addEventListener("enterFrame", moveSquare)
return square
end
right:addEventListener("tap",right)
square = right:tap()
function top:tap() --Top
motionDown = 0;
motionRight = 0;
motionLeft = 0;
motionUp = -speed;
local left = display.newRect(0,0,5,5)
local square = display.newRect( 0, 0, 5, 5 )
square.strokeWidth = 3
square:setFillColor( 0 )
square:setStrokeColor( 0, 0, 0 )
square.x = player.x ; square.y = player.y + 10;
local function moveSquare (event)
square.y = square.y + motionSquare;
end
Runtime:addEventListener("enterFrame", moveSquare)
return square
end
top:addEventListener("tap",top)
square = top:tap()
function bottem:tap(event) --Bottem
motionRight = 0;
motionUp = 0;
motionLeft = 0;
motionDown = speed;
local square = display.newRect( 0, 0, 5, 5 )
square.strokeWidth = 3
square:setFillColor( 0 )
square:setStrokeColor( 0, 0, 0 )
square.x = player.x ; square.y = player.y - 10;
local function moveSquare (event)
square.y = square.y - motionSquare;
end
Runtime:addEventListener("enterFrame", moveSquare)
return square
end
bottem:addEventListener("tap",bottem)
square = bottem:tap()
-- Move character
local function movePlayer (event)
player.x = player.x + motionRight;
if player.x > display.contentWidth then player.x = 0
end
end
Runtime:addEventListener("enterFrame", movePlayer)
local function movePlayer (event)
player.x = player.x + motionLeft;
if player.x < 0 then player.x = display.contentWidth
end
end
Runtime:addEventListener("enterFrame", movePlayer)
local function movePlayer (event)
player.y = player.y + motionUp;
if player.y > display.contentHeight then player.y = 0
end
end
Runtime:addEventListener("enterFrame", movePlayer)
local function movePlayer (event)
player.y = player.y + motionDown;
if player.y < 0 then player.y = display.contentHeight
end
end
Runtime:addEventListener("enterFrame", movePlayer)
local function moveSquare (event)
square.y = square.y + motionSquare;
if player.y < 0 then player.y = display.contentHeight
end
end
Runtime:addEventListener("enterFrame", moveSquare)
Did you already find a solution for this? I already answered a similar question before, I will use the same example:
local function globalTouchHandler(event)
local swipeLength = math.abs(event.x - event.xStart)
print(event.phase, swipeLength)
local t = event.target
local phase = event.phase
if (phase == "began") then
elseif (phase == "moved") then
elseif (phase == "ended" or phase == "cancelled") then
if (event.xStart > event.x and swipeLength > 50) then
-- left
elseif (event.xStart < event.x and swipeLength > 50) then
-- right
end
if (event.y < event.yStart and swipeLength > 50) then
-- up
end
end
end
Runtime:addEventListener("touch",globalTouchHandler)
I am making my own version of admin commands called "Yourself Admin Commands" but unfortunately I broke the fly command function. Yourself Admin Commands is an admin command script made by "Frozeis" on Roblox. Does anyone have any idea how to fix the fly command? Here is the code I have got:
if message == "fly".. prefix and tableContains(owner, player.Name) then
coroutine.resume(coroutine.create(function()
if player and player:findFirstChild("PlayerGui") then
repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:findFirstChild("Torso") and game.Players.LocalPlayer.Character:findFirstChild("Humanoid")
local mouse = game.Players.LocalPlayer:GetMouse()
repeat wait() until mouse
local plr = player
local torso = plr.Character.Torso
local flying = true
local deb = true
local ctrl = {f = 0, b = 0, l = 0, r = 0}
local lastctrl = {f = 0, b = 0, l = 0, r = 0}
local maxspeed = 500
local speed = 0
function Fly()
local bg = Instance.new("BodyGyro", torso)
bg.P = 9e4
bg.maxTorque = Vector3.new(9e9, 9e9, 9e9)
bg.cframe = torso.CFrame
local bv = Instance.new("BodyVelocity", torso)
bv.velocity = Vector3.new(0,0.1,0)
bv.maxForce = Vector3.new(9e9, 9e9, 9e9)
repeat wait()
player.Character.Humanoid.PlatformStand = true
if ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0 then
speed = speed+.5+(speed/maxspeed)
if speed > maxspeed then
speed = maxspeed
end
elseif not (ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0) and speed ~= 0 then
speed = speed-1
if speed < 0 then
speed = 0
end
end
if (ctrl.l + ctrl.r) ~= 0 or (ctrl.f + ctrl.b) ~= 0 then
bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (ctrl.f+ctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(ctrl.l+ctrl.r,(ctrl.f+ctrl.b)*.2,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*speed
lastctrl = {f = ctrl.f, b = ctrl.b, l = ctrl.l, r = ctrl.r}
elseif (ctrl.l + ctrl.r) == 0 and (ctrl.f + ctrl.b) == 0 and speed ~= 0 then
bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (lastctrl.f+lastctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(lastctrl.l+lastctrl.r,(lastctrl.f+lastctrl.b)*.2,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*speed
else
bv.velocity = Vector3.new(0,0.1,0)
end
bg.cframe = game.Workspace.CurrentCamera.CoordinateFrame * CFrame.Angles(-math.rad((ctrl.f+ctrl.b)*50*speed/maxspeed),0,0)
until not flying
ctrl = {f = 0, b = 0, l = 0, r = 0}
lastctrl = {f = 0, b = 0, l = 0, r = 0}
speed = 0
bg:Destroy()
bv:Destroy()
plr.Character.Humanoid.PlatformStand = false
end
mouse.KeyDown:connect(function(key)
if key:lower() == "e" then
if flying then
flying = false
else
flying = true
Fly()
end
elseif key:lower() == "w" then
ctrl.f = 1
elseif key:lower() == "s" then
ctrl.b = -1
elseif key:lower() == "a" then
ctrl.l = -1
elseif key:lower() == "d" then
ctrl.r = 1
end
end)
mouse.KeyUp:connect(function(key)
if key:lower() == "w" then
ctrl.f = 0
elseif key:lower() == "s" then
ctrl.b = 0
elseif key:lower() == "a" then
ctrl.l = 0
elseif key:lower() == "d" then
ctrl.r = 0
end
end)
Fly()
end
end))
end
I'm not sure why it doesn't seem to be working.