NOTE: THIS IS VERY LONG! I HOPE YOU HAVE THE TIME TO READ THIS!
I am making a Town and City game that is like no other. I thought of an idea and thought of a phone system where you can text other players. Sadly, it seems to glitch. I use LocalScripts to allow them to access a Folder in ReplicatedStorage called Numbers. Inside that folder are NumberValues that are named the player's name and the value's value is the number that the player has picked. However, when you set the number it always stays as 0. No matter what. It changes it in the ServerScript so it's not because I'm using a localscript. Also, when I tried changing the value manually in the server test mode all that happened was when you received a text it said "New Text from: 0. Select your phone to read it." It won't change the player's phone number at all! I've tried putting the values inside ReplicatedStorage and inside a folder instead of a model, but that doesn't do anything either! Any help?
There are many scripts used in this system. Main Script inside the PhoneGui:
wait(1)
local Player = script.Parent.Parent.Parent
local Number = game.Workspace.Numbers:FindFirstChild(Player.Name)
local Gui = script.Parent
local frame = Instance.new("Frame")
frame.Position = UDim2.new(1, 0, 0.75, 0)
frame.Size = UDim2.new(1, 0, 0.25, 0)
frame.Style = "DropShadow"
local label = Instance.new("TextLabel", frame)
label.Size = UDim2.new(1, 0, 1, 0)
label.TextColor3 = Color3.new(1, 1, 1)
label.TextStrokeTransparency = 0
label.BackgroundTransparency = 1
label.TextScaled = true
label.TextWrapped = true
num = game.Workspace.Numbers:FindFirstChild(Player.Name)
if Number.Value == 0 then
Gui.NoNum.Visible = true
end
num.ChildAdded:connect(function(child)
local noti = frame:Clone()
for i,v in pairs(script.Parent.NotificationFrame:GetChildren()) do
v:TweenPosition(UDim2.new(0, 0, v.Position.X.Scale-0.25, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.3)
end
noti.Parent = script.Parent.NotificationFrame
noti.TextLabel.Text = "You have received a text from "..child.Name..". Select your phone to read it."
noti:TweenPosition(UDim2.new(0, 0, 0.75, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.5)
end)
script that opens the TextFrame LOCAL:
local mouse = game.Players.LocalPlayer:GetMouse()
local Gui = script.Parent
mouse.KeyDown:connect(function(key)
if key == "q" then
if Gui.TextFrame.Visible then
Gui.TextFrame.Visible = false
else
Gui.TextFrame.Visible = true
end
end
end)
script inside the send button inside the TextFrame:
num = game.Workspace.Numbers:FindFirstChild(script.Parent.Parent.Parent.Parent.Parent.Name)
script.Parent.MouseButton1Down:connect(function()
script.Parent.Text = "Sending..."
wait(0.5)
local sendnum
for i,v in pairs(game.Workspace.Numbers:GetChildren()) do
if v.Value == tonumber(script.Parent.Parent.Number.Text) then
sendnum = v
break
else
sendnum = false
end
end
if sendnum == false then
script.Parent.Text = "ERROR: Number is invalid!"
elseif sendnum ~= false then
local text = Instance.new("StringValue", sendnum)
text.Name = num.Value
text.Value = script.Parent.Parent.Message.Text
script.Parent.Text = "Sent!"
script.Parent.Parent.Message.Text = "Enter Message Here"
end
end)
Main script inside the ReadFrame:
Player = script.Parent.Parent.Parent.Parent
num = game.Workspace.Numbers:FindFirstChild(Player.Name)
local m = Instance.new("TextButton")
m.Size = UDim2.new(1, 0, 0, 45)
m.TextColor3 = Color3.new(1, 1, 1)
m.TextStrokeTransparency = 0
m.TextScaled = true
m.TextWrapped = true
script.Parent.Changed:connect(function(prop)
if prop == "Visible" then
if script.Parent.Visible == true then
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("TextButton") then
if v.Name ~= "From" then
if v.Name ~= "Message" then
v:Destroy()
end
end
end
end
end
local row = 0
for i,v in pairs(num:GetChildren()) do
local text = m:Clone()
text.Parent = script.Parent
text.Name = v.Name
text.Text = "Click to read message from: "..v.Name
text.Position = UDim2.new(0, 0, 0, 45*row)
text.ZIndex = 3
text.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
text.MouseButton1Down:connect(function()
script.Parent.From.Visible = true
script.Parent.Message.Visible = true
script.Parent.From.Text = v.Name
script.Parent.Message.Text = v.Value
text:Destroy()
v:Destroy()
end)
row = row+1
end
end
end)
script inside the message button:
script.Parent.MouseButton1Down:connect(function()
script.Parent.Visible = false
script.Parent.Parent.From.Visible = false
end)
Script inside the NoNum Frame's Enter Button
script.Parent.MouseButton1Down:connect(function()
local num = script.Parent.Text
script.Parent.Text = "Checking Availability..."
script.Parent.BackgroundColor3 = Color3.new(0, 0, 1)
wait(0.5)
local Taken
for i,v in pairs(game.Workspace.Numbers:GetChildren()) do
if v.Value == num then
Taken = true
break
end
end
if Taken then
script.Parent.Text = "That number is already taken!"
script.Parent.BackgroundColor3 = Color3.new(1, 0, 0)
wait(2)
script.Parent.Text = "Enter"
script.Parent.BackgroundColor3 = Color3.new(0, 1, 0)
end
if not Taken then
game.Workspace.Numbers[script.Parent.Parent.Parent.Parent.Parent.Name].Value = num
script.Parent.Text = "Number has been set!"
script.Parent.BackgroundColor3 = Color3.new(0, 1, 0)
wait(2)
script.Parent.Parent.Visible = false
end
end)
LocalScript inside the Phone:
wait(1)
local Player = game.Players.LocalPlayer
local Number = game.Workspace.Numbers:FindFirstChild(Player.Name)
local Tool = script.Parent
local Character = Player.Character
local GlobalMouse = Player:GetMouse()
local Gui = Player.PlayerGui:FindFirstChild("PhoneGui")
Tool.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function()
if not Gui.ReadFrame.Visible then
Gui.ReadFrame.Visible = true
else
Gui.ReadFrame.Visible = false
end
end)
end)
If you need to see the whole thing I can uncopylock the place containing it.

1 comment
Could someone help please? I really want this to work!