So I’m working with a Dev team to make a Hotel group and I came across the idea of a handheld microphone to enable the host of a training to speak with a message. I have made the script for the microphone to work in Workspace, but I am struggling to make the microphone work in StarterPack (as a Tool).
StarterPack layout:
Script:
function onChatted(msg, recipient, speaker)
local source = string.lower(speaker.Name)
msg = string.lower(msg)
local pos1 = script.Parent.Position
local pos2 = speaker.Character.Head.Position
dist=(pos1-pos2).magnitude
dist=dist-math.max(math.max(speaker.Character.Head.Size.x, speaker.Character.Head.Size.z), speaker.Character.Head.Size.y)
if (dist <= 5 and script.Parent.On.Value == true) then
local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = msg
wait(3)
m:remove()
end
end
function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end
game.Players.ChildAdded:connect(onPlayerEntered)
As I say, it works fine in Workspace but I can’t make it work as a Tool.
Any help would be great.