I am trying to do a chat system
when the player clicks ‘SEND’ button local script activates RemoteEvent and it should clone a message bubble to a player’s head
But instead it clones this bubble to everyone’s head
any ideas why?
local script
local Event = game:GetService("ReplicatedStorage"):WaitForChild("FilterMessage")
local send = game:GetService('ReplicatedStorage'):WaitForChild("Chat")
local Input = script.Parent.Parent.TextBox
local Submit = script.Parent
local cooldown = false
local player = game.Players.LocalPlayer
local function buttonClicked()
if Input.Text ~= "" then
cooldown = true
Event:FireServer(Input.Text)
Input.Text = ''
Submit.Visible = false
wait(5)
Submit.Visible = true
cooldown = false
elseif Input.Text == '' then
cooldown = true
Event:FireServer('...')
Submit.Visible = false
wait(5)
Submit.Visible = true
cooldown = false
end
end
local function onClientReceive(message)
send:FireServer(message)
end
Submit.MouseButton1Down:Connect(buttonClicked)
Event.OnClientEvent:Connect(onClientReceive)
--the uhhh enter function
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Return then
if cooldown == false then
cooldown = true
buttonClicked()
Submit.Visible = false
wait(5)
cooldown = false
Submit.Visible = true
end
end
end)
UserInputService.InputBegan:Connect(function(input, focused)
if focused then
return
end
if input.KeyCode == Enum.KeyCode.Slash then
script.Parent.Parent.TextBox:CaptureFocus()
end
end)
server script (the one that clones the message)
local chattingevent = game.ReplicatedStorage:WaitForChild('Chat')
local cooldown = false
chattingevent.OnServerEvent:Connect(function(plr, text)
if cooldown == false then do
local chat = script.chat
local billboard = plr.Character.Head:WaitForChild('BillboardGui')
billboard.ExtentsOffset = Vector3.new(0, 4, 0)
chat.TextLabel.Text = text
local cloned = chat:Clone()
cloned.Parent = plr.Character.Head
wait(5)
billboard.ExtentsOffset = Vector3.new(0, 2, 0)
cloned:Destroy()
end
end
end)