I cant see the problem? (Position is not a valid member of LocalScript)
Asked by
5 years ago Edited 5 years ago
So i was trying to make a custom chat, there are 2 scripts, the other in ServerScriptService is working alright, but the script inside the chat is not, its the script that shows the message.
SCRIPTS:
The Faulty Script:
01 | local Player = game.Players.LocalPlayer |
02 | local OriginalText = "Click here or press '/' to send a message" |
03 | local Chat = script.Parent |
04 | local ChatFrame = script.Parent.MainCustomChatWindow |
05 | local ChatBar = script.Parent.MainCustomChatWindow.SendChatFrame.PlayerSendBox |
06 | local Frame = script.Parent.MainCustomChatWindow.PlayerTextBoxHolder |
07 | local UIS = game:GetService( "UserInputService" ) |
08 | if UIS.TouchEnabled then |
09 | OriginalText = OriginalText |
10 | ChatBar.Text = OriginalText |
12 | UIS.InputBegan:Connect( function (Input, GameProcessed) |
13 | if GameProcessed then return end |
14 | if Input.KeyCode = = Enum.KeyCode.Slash then |
15 | ChatBar:CaptureFocus() |
18 | local function ChatFunction(Message) |
19 | game.ReplicatedStorage.Message:FireServer(Message) |
21 | ChatBar.FocusLost:Connect( function (EnterPressed) |
23 | local Message = ChatBar.Text |
24 | if Message:len() > 0 then |
27 | if Message:lower() = = Message:upper() and Message ~ = "" and Message ~ = " " and Message ~ = " " and Message ~ = " " and Message ~ = " " and Message ~ = " " and Message ~ = " " and Message ~ = " " then |
32 | ChatBar.Text = OriginalText |
34 | ChatFrame.MouseEnter:Connect( function () |
35 | ChatBar.BackgroundTransparency = 0 |
36 | Frame.BackgroundTransparency = 0 |
38 | ChatBar.BackgroundTransparency = ChatBar.BackgroundTransparency + 0.04 |
39 | Frame.BackgroundTransparency = Frame.BackgroundTransparency + 0.04 |
42 | ChatBar.BackgroundTransparency = 0.77 |
43 | Frame.BackgroundTransparency = 0.77 |
45 | ChatFrame.MouseLeave:Connect( function () |
46 | ChatBar.BackgroundTransparency = 0.77 |
47 | Frame.BackgroundTransparency = 0.77 |
49 | ChatBar.BackgroundTransparency = ChatBar.BackgroundTransparency - 0.04 |
50 | Frame.BackgroundTransparency = Frame.BackgroundTransparency - 0.04 |
53 | ChatBar.BackgroundTransparency = 0 |
54 | Frame.BackgroundTransparency = 0 |
56 | game.ReplicatedStorage.Message.OnClientEvent:Connect( function (Message) |
57 | local i = Instance.new( "TextLabel" ,Frame) |
58 | i.Size = UDim 2. new( 1 , 0 , 0.1 , 0 ) |
60 | i.BackgroundTransparency = 1 |
61 | i.Font = Enum.Font.SciFi |
62 | i.TextStrokeTransparency = 0 |
63 | i.TextColor 3 = Color 3. new( 235 , 235 , 233 ) |
66 | i.TextXAlignment = Enum.TextXAlignment.Left |
67 | i.TextYAlignment = Enum.TextYAlignment.Top |
68 | local t = Frame:GetChildren() |
69 | Frame:ClearAllChildren() |
73 | for c,v in pairs (t) do |
75 | l.Position = UDim 2. new( 0 , 0 , (c- 1 )* 0.1 , 0 ) |
It is inside the ScreenGui of the Chat, not inside the ChatFrame so script.Parent = ScreenGui
It is probably cloning itself and trying to find Position on it, which does not exist but I don't know how to fix it or why it is happening
It is having errors at line 75: l.Position = UDim2.new(0,0, (c-1)*0.1,0)
This is a LocalScript
And the other script:
01 | local ReplicatedStorage = game.ReplicatedStorage |
02 | local MessageEvent = ReplicatedStorage.Message |
04 | local Owners = { "166660143" , "260932086" } |
05 | local Admins = { "166660143" , "260932086" , "1466856081" , "310333010" } |
06 | local function IsOwner(p) |
08 | for _,v in pairs (Owners) do |
15 | local function isAdmin(p) |
17 | for _,v in pairs (Admins) do |
24 | local function Chat (p,m) |
26 | local Message = game.Chat:FilterStringForBroadcast(m,p) |
27 | local Nick = p:FindFirstChild( "Nickname" ) if Nick then Name = p.Nickname.Value end |
28 | local Prefix = p:FindFirstChild( "Prefix" ) if Prefix then Name = "[" ..p.Prefix.Value.. "]" ..Name end |
29 | for _,v in pairs (game.Players:GetPlayers()) do |
30 | if not v:WaitForChild( "Muted" ):FindFirstChild(p.Name) then |
31 | MessageEvent:FireClient(v,Name.. ": " ..Message:sub( 1 , 50 )) |
35 | local function SPM(p,m) |
36 | MessageEvent:FireClient(p, "SERVER: " ..m) |
39 | MessageEvent:FireAllClients( "SERVER: " ..m) |
42 | MessageEvent:FireAllClients(m) |
44 | local function PRAW(p,m) |
45 | MessageEvent:FireClient(p,m) |
47 | local function Whisper(p,v,m) |
49 | local Message = game.Chat:FilterStringForBroadcast(m,p) |
50 | local Nickname = p.FindFirstChild( "Nickname" ) if Nickname then Name = p.Nickname.Value end |
51 | local Prefix = p:FindFirstChild( "Prefix" ) if Prefix then Name = "[" ..p.Prefix.Value.. "]" ..Name end |
52 | if v:WaitForChild( "Muted" ):FindFirstChild(p.Name) then |
53 | PRAW(p,v.Name.. " has muted you!" ) |
55 | PRAW(p, "Message Sent To " ..v.Name) |
56 | PRAW(v, "From " ..Name.. ": " ..Message:sub( 1 , 40 )) |
59 | MessageEvent.OnServerEvent:Connect( function (p,m) |
60 | if m:sub( 1 , 6 ):lower() = = "/mute " then |
62 | elseif m:sub( 1 , 8 ):lower() = = "unmute " then |
64 | elseif m:sub( 1 , 3 ):lower() = = "/w" then |
66 | elseif m:sub( 1 , 1 ) = = APrefix and isAdmin(p) then |
73 | game.Players.PlayerAdded:Connect( function (p) |
74 | local mutedfolder = Instance.new( "Folder" ,p) |
75 | mutedfolder.Name = "Muted" |
Which appears to have no errors at all and is a normal Script