OXYTICK
(OXYTICK)
February 24, 2021, 4:38am
#1
So I’m trying to make it when reason changes, it gets updated and gets sent. How would I do this?
local reason = script.Parent.Parent.Reason.Text
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Remotes.sendCall:FireServer(reason)
end)
lluckvy
(aaron)
February 24, 2021, 4:44am
#2
You can use .FocusLost
on the TextBox, and once the player clicks enter it will update (still a little confused on what you’re trying to get at, your description is a bit vague)
local reason = script.Parent.Parent.Reason
local sendCall = game.ReplicatedStorage:WaitForChild('Remotes').sendCall
reason.FocusLost:Connect(function(enterPressed)
if enterPressed then
sendCall:FireServer(reason.Text)
end
end)
OXYTICK
(OXYTICK)
February 24, 2021, 4:46am
#3
This doesn’t work, and adding on to my description, I mean like when the variable reason changes, which is connected to script.Parent.Parent.Reason.Text, so when the text changes, it gets updated.
lluckvy
(aaron)
February 24, 2021, 4:47am
#4
Could I see the script which receives the event?
OXYTICK
(OXYTICK)
February 24, 2021, 4:51am
#5
local sendCall = game.ReplicatedStorage.Remotes.sendCall
local acceptCall = game.ReplicatedStorage.Remotes.acceptCall
local count = 0
function createCall(parent, txt)
local CallTxt = Instance.new("TextLabel")
local AcceptBtn = Instance.new("TextButton")
CallTxt.Name = "Call"..tostring(count)
CallTxt.Parent = parent
CallTxt.Active = true
CallTxt.BackgroundColor3 = Color3.new(0.117647, 0.117647, 0.117647)
CallTxt.BorderColor3 = Color3.fromRGB(255, 255, 255)
CallTxt.BorderSizePixel = 1
CallTxt.Position = UDim2.new(1.70679968e-08, 0, 0, 0)
CallTxt.Size = UDim2.new(0, 341, 0, 28)
CallTxt.Font = Enum.Font.SourceSansBold
CallTxt.Text = tostring(txt)
CallTxt.TextColor3 = Color3.new(1, 1, 1)
CallTxt.TextSize = 14
AcceptBtn.Name = "Accept"
AcceptBtn.Parent = CallTxt
AcceptBtn.BackgroundColor3 = Color3.new(0.105882, 0.45098, 0.101961)
AcceptBtn.BorderColor3 = Color3.fromRGB(255, 255, 255)
AcceptBtn.BorderSizePixel = 1
AcceptBtn.Position = UDim2.new(0.997123718, 0, 0, 0)
AcceptBtn.Size = UDim2.new(0, 88, 0, 28)
AcceptBtn.AutoButtonColor = true
AcceptBtn.Font = Enum.Font.SourceSansBold
AcceptBtn.Text = "ACCEPT"
AcceptBtn.TextColor3 = Color3.new(1, 1, 1)
AcceptBtn.TextSize = 14
AcceptBtn.MouseButton1Click:Connect(function()
for i, v in pairs(game.Players:GetChildren()) do
if v.Team.Name == "Police" or "Fire Department" or "EMT" or "DOT " or "Agency" then
if AcceptBtn.Text ~= "Accepted" then
acceptCall:FireClient(v, "Call"..tostring(string.sub(AcceptBtn.Parent.Name, 5)))
v.PlayerGui.CallDB.mFrame.IncomingCalls["Call"..tostring(string.sub(AcceptBtn.Parent.Name, 5))].Accept.BackgroundColor3 = Color3.fromRGB(71, 39, 255)
v.PlayerGui.CallDB.mFrame.IncomingCalls["Call"..tostring(string.sub(AcceptBtn.Parent.Name, 5))].Accept.Text = "ACCEPTED"
end
end
end
end)
count = count + 1
end
sendCall.OnServerEvent:Connect(function(plr, call)
for i, v in pairs(game.Players:GetChildren()) do
if v.Team.Name == "Police" or "Fire Department" or "EMT" or "DOT " or "Agency" then
createCall(v.PlayerGui.CallDB.mFrame.IncomingCalls, call)
end
end
end)
lluckvy
(aaron)
February 24, 2021, 4:55am
#6
When comparing strings you will have to address it for every string, so it should instead be
if v.Team.Name == "Police" or v.Team.Name == "Fire Department" or v.Team.Name == "EMT" or v.Team.Name == "DOT " or v.Team.Name == "Agency" then
OXYTICK
(OXYTICK)
February 24, 2021, 4:55am
#7
Haven’t done that yet, pretty tired as it’s almost 10 for me.
OXYTICK
(OXYTICK)
February 24, 2021, 4:56am
#8
I do know that there is something that detects change, which I believe it’s .Change, but I don’t know how to implement it in the first script.
local reason = script.Parent.Parent.Reason
reason:GetPropertyChangedSignal("Text"):Connect(function()
game.ReplicatedStorage.Remotes.sendCall:FireServer(reason.Text)
end)
OXYTICK
(OXYTICK)
February 24, 2021, 5:04am
#10
This doesn’t work either, everytime I type in the specified area it’ll automatically send it. I tried to connect script.Parent to a MouseButton1Click but it doesn’t work anymore.
OXYTICK
(OXYTICK)
February 24, 2021, 5:05am
#11
Nevermind, I just fixed it. Thank you!
OXYTICK
(OXYTICK)
February 24, 2021, 5:07am
#12
The final script was
local reason = script.Parent.Parent.Reason
reason:GetPropertyChangedSignal("Text"):Connect(function()
end)
script.parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Remotes.sendCall:FireServer(reason.Text)
end)